Content-Length: 280858 | pFad | http://github.com/apache/airflow/pull/50741/files

29 Added test to verify decorator signature matches KubernetesPodOperator by Shashwatpandey4 · Pull Request #50741 · apache/airflow · GitHub
Skip to content

Added test to verify decorator signature matches KubernetesPodOperator #50741

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions tests/decorators/test_operator_decorator_signature_sync.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

from __future__ import annotations

import inspect

import pytest

from airflow.providers.cncf.kubernetes.decorators.kubernetes import kubernetes_task
from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator


def extract_init_param_names(cls):
sig = inspect.signature(cls.__init__)
return {
name for name, param in sig.parameters.items() if name != "self" and param.kind != param.VAR_KEYWORD
}


def extract_decorator_param_names(decorator_func):
sig = inspect.signature(decorator_func)
return {name for name, param in sig.parameters.items() if param.kind != param.VAR_KEYWORD}


def test_kubernetes_task_decorator_signature_matches_operator():
operator_params = extract_init_param_names(KubernetesPodOperator)
decorator_params = extract_decorator_param_names(kubernetes_task)

# Ignore decorator-specific arguments
ignored_params = {"python_callable", "multiple_outputs"}
filtered_decorator_params = decorator_params - ignored_params

# These operator params should be present in the decorator
missing_params = operator_params - filtered_decorator_params

if missing_params:
pytest.fail(
f"The following KubernetesPodOperator params are missing from the "
f"kubernetes_task decorator: {sorted(missing_params)}"
)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/apache/airflow/pull/50741/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy