Repository: incubator-airflow
Updated Branches:
  refs/heads/master 15b8b7a85 -> 6f6030452


[AIRFLOW-1793] Use docker_url instead of invalid base_url

Closes #2998 from kodieg/patch-3


Project: http://git-wip-us.apache.org/repos/asf/incubator-airflow/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-airflow/commit/6f603045
Tree: http://git-wip-us.apache.org/repos/asf/incubator-airflow/tree/6f603045
Diff: http://git-wip-us.apache.org/repos/asf/incubator-airflow/diff/6f603045

Branch: refs/heads/master
Commit: 6f60304529a6db0fc050590b821b288d64dcd992
Parents: 15b8b7a
Author: kodieg <goluchow...@so1.net>
Authored: Sun Feb 4 14:39:14 2018 +0100
Committer: Fokko Driesprong <fokkodriespr...@godatadriven.com>
Committed: Sun Feb 4 14:39:14 2018 +0100

----------------------------------------------------------------------
 airflow/operators/docker_operator.py |  2 +-
 tests/operators/docker_operator.py   | 13 ++++++-------
 2 files changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/6f603045/airflow/operators/docker_operator.py
----------------------------------------------------------------------
diff --git a/airflow/operators/docker_operator.py 
b/airflow/operators/docker_operator.py
index 38edc8b..adaabd2 100644
--- a/airflow/operators/docker_operator.py
+++ b/airflow/operators/docker_operator.py
@@ -147,7 +147,7 @@ class DockerOperator(BaseOperator):
     def get_hook(self):
         return DockerHook(
             docker_conn_id=self.docker_conn_id,
-            base_url=self.base_url,
+            base_url=self.docker_url,
             version=self.api_version,
             tls=self.__get_tls_config()
         )

http://git-wip-us.apache.org/repos/asf/incubator-airflow/blob/6f603045/tests/operators/docker_operator.py
----------------------------------------------------------------------
diff --git a/tests/operators/docker_operator.py 
b/tests/operators/docker_operator.py
index a12b6f8..9ff60d2 100644
--- a/tests/operators/docker_operator.py
+++ b/tests/operators/docker_operator.py
@@ -187,8 +187,10 @@ class DockerOperatorTestCase(unittest.TestCase):
             'Hook called though no docker_conn_id configured'
         )
 
+    @mock.patch('airflow.operators.docker_operator.DockerHook')
     @mock.patch('airflow.operators.docker_operator.Client')
-    def test_execute_with_docker_conn_id_use_hook(self, operator_client_mock):
+    def test_execute_with_docker_conn_id_use_hook(self, operator_client_mock,
+                                                  operator_docker_hook):
         # Mock out a Docker client, so operations don't raise errors
         client_mock = mock.Mock(name='DockerOperator.Client mock', spec=Client)
         client_mock.images.return_value = []
@@ -209,19 +211,16 @@ class DockerOperatorTestCase(unittest.TestCase):
         # Mock out the DockerHook
         hook_mock = mock.Mock(name='DockerHook mock', spec=DockerHook)
         hook_mock.get_conn.return_value = client_mock
-        operator.get_hook = mock.Mock(
-            name='DockerOperator.get_hook mock',
-            spec=DockerOperator.get_hook,
-            return_value=hook_mock
-        )
+        operator_docker_hook.return_value = hook_mock
 
         operator.execute(None)
+
         self.assertEqual(
             operator_client_mock.call_count, 0,
             'Client was called on the operator instead of the hook'
         )
         self.assertEqual(
-            operator.get_hook.call_count, 1,
+            operator_docker_hook.call_count, 1,
             'Hook was not called although docker_conn_id configured'
         )
         self.assertEqual(

Reply via email to