eladkal commented on a change in pull request #14960:
URL: https://github.com/apache/airflow/pull/14960#discussion_r606923303
##########
File path: tests/providers/docker/operators/test_docker_swarm.py
##########
@@ -148,27 +148,31 @@ def test_no_auto_remove(self, types_mock,
client_class_mock):
@mock.patch('airflow.providers.docker.operators.docker.APIClient')
@mock.patch('airflow.providers.docker.operators.docker_swarm.types')
- def test_failed_service_raises_error(self, types_mock, client_class_mock):
+ def test_non_complete_service_raises_error(self, types_mock,
client_class_mock):
mock_obj = mock.Mock()
client_mock = mock.Mock(spec=APIClient)
client_mock.create_service.return_value = {'ID': 'some_id'}
client_mock.images.return_value = []
client_mock.pull.return_value = [b'{"status":"pull log"}']
- client_mock.tasks.return_value = [{'Status': {'State': 'failed'}}]
types_mock.TaskTemplate.return_value = mock_obj
types_mock.ContainerSpec.return_value = mock_obj
types_mock.RestartPolicy.return_value = mock_obj
types_mock.Resources.return_value = mock_obj
client_class_mock.return_value = client_mock
- operator = DockerSwarmOperator(image='', auto_remove=False,
task_id='unittest', enable_logging=False)
+ non_complete_statuses = ['failed', 'shutdown', 'rejected', 'orphaned',
'remove']
msg = "Service did not complete: {'ID': 'some_id'}"
- with pytest.raises(AirflowException) as ctx:
- operator.execute(None)
- assert str(ctx.value) == msg
+ for status in non_complete_statuses:
Review comment:
can you convert the loop to` parameterized.expand` ?
see examples:
https://github.com/apache/airflow/blob/e86f5ca8fa5ff22c1e1f48addc012919034c672f/tests/providers/amazon/aws/sensors/test_step_function_execution.py#L52
https://github.com/apache/airflow/blob/0f327788b5b0887c463cb83dd8f732245da96577/tests/providers/tableau/sensors/test_tableau_job_status.py#L53
--
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]