mik-laj commented on a change in pull request #10546:
URL: https://github.com/apache/airflow/pull/10546#discussion_r476365583
##########
File path: tests/providers/docker/operators/test_docker.py
##########
@@ -32,23 +32,32 @@
class TestDockerOperator(unittest.TestCase):
- @mock.patch('airflow.providers.docker.operators.docker.TemporaryDirectory')
- @mock.patch('airflow.providers.docker.operators.docker.APIClient')
- def test_execute(self, client_class_mock, tempdir_mock):
- host_config = mock.Mock()
- tempdir_mock.return_value.__enter__.return_value = '/mkdtemp'
-
- client_mock = mock.Mock(spec=APIClient)
- client_mock.create_container.return_value = {'Id': 'some_id'}
- client_mock.create_host_config.return_value = host_config
- client_mock.images.return_value = []
- client_mock.attach.return_value = ['container log']
- client_mock.logs.return_value = ['container log']
- client_mock.pull.return_value = {"status": "pull log"}
- client_mock.wait.return_value = {"StatusCode": 0}
+ def setUp(self):
+ self.tempdir_patch = mock.patch(
+ 'airflow.providers.docker.operators.docker.TemporaryDirectory',
+ )
Review comment:
See:
https://docs.python.org/3/library/unittest.mock.html#patch-methods-start-and-stop
----------------------------------------------------------------
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:
[email protected]