Bowrna commented on pull request #21145:
URL: https://github.com/apache/airflow/pull/21145#issuecomment-1047052751


   @potiuk One of the tests that I tried writing with mock patch was failing. I 
am not sure where I am going wrong. 
   
   ```
   @mock.patch('airflow_breeze.utils.docker_command_utils.run_command')
       @mock.patch('airflow_breeze.utils.docker_command_utils.console')
       def test_check_docker_compose_version_ok(mock_console, mock_run_command):
           mock_run_command.return_value.returncode = 0
           mock_run_command.return_value.stdout = "1.29"
           check_docker_compose_version(verbose=True)
           mock_run_command.assert_called_with(
                   ["docker-compose", "--version"],
                   verbose=True,
                   suppress_console_print=True,
                   capture_output=True,
                   text=True,
               )
   >       mock_console.print.assert_called_with("Good version of 
docker-compose: 1.29")
   
   dev/breeze/tests/test_docker_command_utils.py:156: 
   _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
_ _ 
   
   _mock_self = <MagicMock name='console.print' 
id='13971730345[96](https://github.com/apache/airflow/runs/5277010738?check_suite_focus=true#step:5:96)00'>
   args = ('Good version of docker-compose: 1.29',), kwargs = {}
   expected = "print('Good version of docker-compose: 1.29')"
   
       def assert_called_with(_mock_self, *args, **kwargs):
           """assert that the mock was called with the specified arguments.
       
           Raises an AssertionError if the args and keyword args passed in are
           different to the last call to the mock."""
           self = _mock_self
           if self.call_args is None:
               expected = self._format_mock_call_signature(args, kwargs)
   >           raise AssertionError('Expected call: %s\nNot called' % 
(expected,))
   E           AssertionError: Expected call: print('Good version of 
docker-compose: 1.29')
   E           Not called
   
   /opt/hostedtoolcache/Python/3.7.12/x64/lib/python3.7/unittest/mock.py:869: 
AssertionError
   ```


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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to