[AIRFLOW-1793] Use docker_url instead of invalid base_url
Closes #2998 from kodieg/patch-3
This commit is contained in:
Родитель
15b8b7a851
Коммит
6f60304529
|
@ -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()
|
||||
)
|
||||
|
|
|
@ -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(
|
||||
|
|
Загрузка…
Ссылка в новой задаче