def test_api_call_with_timeout(): func = mock.Mock( side_effect=requests.exceptions.ReadTimeout("msg"), __name__="remove_image") id = "abcd" with mock.patch( 'docker_custodian.docker_gc.log', autospec=True) as mock_log: docker_gc.api_call(func, id) func.assert_called_once_with(id) mock_log.warn.assert_called_once_with('Failed to call remove_image abcd msg')
def test_api_call_with_api_error(): func = mock.Mock(side_effect=docker.errors.APIError("Ooops", mock.Mock( status_code=409, reason="Conflict"), explanation="failed"), __name__="remove_image") image = "abcd" with mock.patch('docker_custodian.docker_gc.log', autospec=True) as mock_log: docker_gc.api_call(func, image=image) func.assert_called_once_with(image="abcd") mock_log.warn.assert_called_once_with( 'Error calling remove_image image=abcd ' '409 Client Error: Conflict ("failed")')
def test_api_call_with_api_error(): func = mock.Mock( side_effect=docker.errors.APIError( "Ooops", mock.Mock(status_code=409, reason="Conflict"), explanation="failed"), __name__="remove_image") id = "abcd" with mock.patch( 'docker_custodian.docker_gc.log', autospec=True) as mock_log: docker_gc.api_call(func, id) func.assert_called_once_with(id) mock_log.warn.assert_called_once_with( 'Error calling remove_image abcd ' '409 Client Error: Conflict ("failed")')
def test_api_call_success(): func = mock.Mock() container = "abcd" result = docker_gc.api_call(func, container=container) func.assert_called_once_with(container="abcd") assert result == func.return_value
def test_api_call_success(): func = mock.Mock() id = "abcd" result = docker_gc.api_call(func, id) func.assert_called_once_with(id) assert result == func.return_value