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/08/17 02:27:24 UTC

[GitHub] [airflow] coopergillan opened a new pull request #10353: Expand JenkinsJobTriggerOperator unit tests

coopergillan opened a new pull request #10353:
URL: https://github.com/apache/airflow/pull/10353


   Using the `parameterized` library, add unit test coverage for `JenkinsJobTriggerOperator` parameters. Previously the tests only covered parameters given as a dictionary, but now it will cover a string and list, which are all acceptable input.
   
    closes: #10132
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
   In case of fundamental code change, Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals)) is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in [UPDATING.md](https://github.com/apache/airflow/blob/master/UPDATING.md).
   


----------------------------------------------------------------
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



[GitHub] [airflow] turbaszek commented on a change in pull request #10353: Expand JenkinsJobTriggerOperator unit tests

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #10353:
URL: https://github.com/apache/airflow/pull/10353#discussion_r471302720



##########
File path: tests/providers/jenkins/operators/test_jenkins_job_trigger.py
##########
@@ -20,15 +20,23 @@
 
 import jenkins
 import mock
+from parameterized import parameterized
 
 from airflow.exceptions import AirflowException
 from airflow.providers.jenkins.hooks.jenkins import JenkinsHook
 from airflow.providers.jenkins.operators.jenkins_job_trigger import JenkinsJobTriggerOperator
 
+TEST_PARAMS = [
+    ({'a_param': 'blip', 'another_param': '42'},),
+    ('{"a_param": "blip", "another_param": "42"}',),
+    (['a_param', 'blip', 'another_param', '42'],),
+]
+
 
 class TestJenkinsOperator(unittest.TestCase):
+    @parameterized.expand(TEST_PARAMS)
     @unittest.skipIf(mock is None, 'mock package not present')
-    def test_execute(self):
+    def test_execute(self, the_parameters):

Review comment:
       ```suggestion
       def test_execute(self, parameters):
   ```
   Lets rename it using the opportunity :)




----------------------------------------------------------------
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



[GitHub] [airflow] turbaszek commented on a change in pull request #10353: Expand JenkinsJobTriggerOperator unit tests

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #10353:
URL: https://github.com/apache/airflow/pull/10353#discussion_r471302621



##########
File path: tests/providers/jenkins/operators/test_jenkins_job_trigger.py
##########
@@ -20,15 +20,23 @@
 
 import jenkins
 import mock
+from parameterized import parameterized
 
 from airflow.exceptions import AirflowException
 from airflow.providers.jenkins.hooks.jenkins import JenkinsHook
 from airflow.providers.jenkins.operators.jenkins_job_trigger import JenkinsJobTriggerOperator
 
+TEST_PARAMS = [
+    ({'a_param': 'blip', 'another_param': '42'},),
+    ('{"a_param": "blip", "another_param": "42"}',),
+    (['a_param', 'blip', 'another_param', '42'],),
+]
+
 
 class TestJenkinsOperator(unittest.TestCase):
+    @parameterized.expand(TEST_PARAMS)

Review comment:
       I personally prefer when the dict is placed in the decorator - no need to look for test cases :)

##########
File path: tests/providers/jenkins/operators/test_jenkins_job_trigger.py
##########
@@ -20,15 +20,23 @@
 
 import jenkins
 import mock
+from parameterized import parameterized
 
 from airflow.exceptions import AirflowException
 from airflow.providers.jenkins.hooks.jenkins import JenkinsHook
 from airflow.providers.jenkins.operators.jenkins_job_trigger import JenkinsJobTriggerOperator
 
+TEST_PARAMS = [
+    ({'a_param': 'blip', 'another_param': '42'},),
+    ('{"a_param": "blip", "another_param": "42"}',),
+    (['a_param', 'blip', 'another_param', '42'],),
+]
+
 
 class TestJenkinsOperator(unittest.TestCase):
+    @parameterized.expand(TEST_PARAMS)
     @unittest.skipIf(mock is None, 'mock package not present')
-    def test_execute(self):
+    def test_execute(self, the_parameters):

Review comment:
       ```suggestion
       def test_execute(self, parameters):
   ```




----------------------------------------------------------------
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



[GitHub] [airflow] coopergillan commented on a change in pull request #10353: Expand JenkinsJobTriggerOperator unit tests

Posted by GitBox <gi...@apache.org>.
coopergillan commented on a change in pull request #10353:
URL: https://github.com/apache/airflow/pull/10353#discussion_r471553941



##########
File path: tests/providers/jenkins/operators/test_jenkins_job_trigger.py
##########
@@ -20,15 +20,23 @@
 
 import jenkins
 import mock
+from parameterized import parameterized
 
 from airflow.exceptions import AirflowException
 from airflow.providers.jenkins.hooks.jenkins import JenkinsHook
 from airflow.providers.jenkins.operators.jenkins_job_trigger import JenkinsJobTriggerOperator
 
+TEST_PARAMS = [
+    ({'a_param': 'blip', 'another_param': '42'},),
+    ('{"a_param": "blip", "another_param": "42"}',),
+    (['a_param', 'blip', 'another_param', '42'],),
+]
+
 
 class TestJenkinsOperator(unittest.TestCase):
+    @parameterized.expand(TEST_PARAMS)
     @unittest.skipIf(mock is None, 'mock package not present')
-    def test_execute(self):
+    def test_execute(self, the_parameters):

Review comment:
       Good call. Just pushed this and a few other changes up 😅




----------------------------------------------------------------
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



[GitHub] [airflow] kaxil merged pull request #10353: Expand JenkinsJobTriggerOperator unit tests

Posted by GitBox <gi...@apache.org>.
kaxil merged pull request #10353:
URL: https://github.com/apache/airflow/pull/10353


   


----------------------------------------------------------------
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



[GitHub] [airflow] coopergillan commented on pull request #10353: Expand JenkinsJobTriggerOperator unit tests

Posted by GitBox <gi...@apache.org>.
coopergillan commented on pull request #10353:
URL: https://github.com/apache/airflow/pull/10353#issuecomment-674632213


   @turbaszek had a look at the original PR that this grew out of.


----------------------------------------------------------------
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



[GitHub] [airflow] coopergillan commented on a change in pull request #10353: Expand JenkinsJobTriggerOperator unit tests

Posted by GitBox <gi...@apache.org>.
coopergillan commented on a change in pull request #10353:
URL: https://github.com/apache/airflow/pull/10353#discussion_r471561676



##########
File path: tests/providers/jenkins/operators/test_jenkins_job_trigger.py
##########
@@ -20,15 +20,21 @@
 
 import jenkins
 import mock
+from parameterized import parameterized
 
 from airflow.exceptions import AirflowException
 from airflow.providers.jenkins.hooks.jenkins import JenkinsHook
 from airflow.providers.jenkins.operators.jenkins_job_trigger import JenkinsJobTriggerOperator
 
 
+@unittest.skipIf(mock is None, 'mock package not present')

Review comment:
       Coming to think of it, I think this line doesn't make sense. Wouldn't we need to add this up in the imports?
   
   ```python
   try:
       import mock
   except ImportError:
       mock = None
   ```




----------------------------------------------------------------
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



[GitHub] [airflow] turbaszek commented on a change in pull request #10353: Expand JenkinsJobTriggerOperator unit tests

Posted by GitBox <gi...@apache.org>.
turbaszek commented on a change in pull request #10353:
URL: https://github.com/apache/airflow/pull/10353#discussion_r471973026



##########
File path: tests/providers/jenkins/operators/test_jenkins_job_trigger.py
##########
@@ -20,15 +20,21 @@
 
 import jenkins
 import mock
+from parameterized import parameterized
 
 from airflow.exceptions import AirflowException
 from airflow.providers.jenkins.hooks.jenkins import JenkinsHook
 from airflow.providers.jenkins.operators.jenkins_job_trigger import JenkinsJobTriggerOperator
 
 
+@unittest.skipIf(mock is None, 'mock package not present')

Review comment:
       Let's just do `from unittest import mock` and remove the skipIf




----------------------------------------------------------------
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



[GitHub] [airflow] coopergillan commented on pull request #10353: Expand JenkinsJobTriggerOperator unit tests

Posted by GitBox <gi...@apache.org>.
coopergillan commented on pull request #10353:
URL: https://github.com/apache/airflow/pull/10353#issuecomment-674632053


   CI failure looks unrelated?


----------------------------------------------------------------
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