You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/12/02 09:01:27 UTC

[GitHub] [airflow] turbaszek commented on a change in pull request #12660: Add upgrade check rule for unrecognized arguments to Operators

turbaszek commented on a change in pull request #12660:
URL: https://github.com/apache/airflow/pull/12660#discussion_r533998393



##########
File path: tests/upgrade/rules/test_no_additional_args_operators.py
##########
@@ -0,0 +1,49 @@
+# 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 tempfile import NamedTemporaryFile
+from unittest import TestCase
+import textwrap
+from airflow.upgrade.rules.no_additional_args_in_operators import NoAdditionalArgsInOperatorsRule
+from tests.test_utils.db import clear_db_connections
+
+
+class TestNoAdditionalArgsInOperatorsRule(TestCase):
+    def tearDown(self):
+        clear_db_connections()
+
+    def test_check(self):
+        rule = NoAdditionalArgsInOperatorsRule()
+
+        assert isinstance(rule.title, str)
+        assert isinstance(rule.description, str)
+
+        with NamedTemporaryFile(mode='w', suffix='.py') as dag_file:
+            dag_file.write(
+                textwrap.dedent('''
+            from airflow import DAG
+            from airflow.utils.dates import days_ago
+            from airflow.operators.bash_operator import BashOperator
+
+            with DAG(dag_id="test", start_date=days_ago(0)):
+                BashOperator(task_id='test', bash_command="true", extra_param=42)
+                '''
+                                ))
+            dag_file.flush()
+            msgs = rule.check(dags_folder=dag_file.name)

Review comment:
       > @turbaszek Since you and I don't agree, and both approaches already exist in the code base, are you happy to let @Dr-Denzy decide on which approach to user?
   
   Yes, no objection to keep it as it is - we already use this approach 👌 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org