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/26 19:27:01 UTC

[GitHub] [airflow] kaxil commented on a change in pull request #10546: DockerOperator extra_hosts argument support added

kaxil commented on a change in pull request #10546:
URL: https://github.com/apache/airflow/pull/10546#discussion_r477537654



##########
File path: tests/providers/docker/operators/test_docker.py
##########
@@ -298,3 +249,22 @@ def test_execute_xcom_behavior(self, client_class_mock, tempdir_mock):
 
         self.assertEqual(xcom_push_result, b'container log')
         self.assertIs(no_xcom_push_result, None)
+
+    def test_extra_hosts(self):
+        hosts_obj = mock.Mock()
+        operator = \
+            DockerOperator(task_id='test', image='test', extra_hosts=hosts_obj)
+        operator.execute(None)
+        self.client_mock.create_container.assert_called_once()
+        self.assertIn(
+            'host_config',
+            self.client_mock.create_container.call_args.kwargs,
+        )
+        self.assertIn(
+            'extra_hosts',
+            self.client_mock.create_host_config.call_args.kwargs,
+        )
+        self.assertIs(
+            hosts_obj,
+            self.client_mock.create_host_config.call_args.kwargs['extra_hosts'],
+        )

Review comment:
       Instead of passing mock object to `hosts_obj` why not pass a dictionary and check that it is used in mock_call




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