tests/integration: update some tests for updated error-messages

I was in the process of cleaning up some error-messages, and it looks like
the docker-py tests were depending on strings that will be removed;

    =================================== FAILURES ===================================
    _____________ CreateContainerTest.test_create_with_restart_policy ______________
    tests/integration/api_container_test.py:126: in test_create_with_restart_policy
        assert 'You cannot remove ' in err
    E   AssertionError: assert 'You cannot remove ' in 'cannot remove container d11580f6078108691096ec8a23404a6bda9ad1d1b2bafe88b17d127a67728833: container is restarting: stop the container before removing or force remove'
    ____________________ ErrorsTest.test_api_error_parses_json _____________________
    tests/integration/errors_test.py:13: in test_api_error_parses_json
        assert 'You cannot remove a running container' in explanation
    E   AssertionError: assert 'You cannot remove a running container' in 'cannot remove container 4b90ce2e907dd0f99d0f561619b803e7a2a31809ced366c537874dd13f8a47ec: container is running: stop the container before removing or force remove'

This updates the tests to match on a string that will be present in both the
old and new error-messages, but added a "lower()", so that matching will be
done case-insensitive (Go errors generally should be lowercase).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-08-14 10:17:25 +02:00
parent 54ec0c6bf7
commit 5064995bc4
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 4 additions and 4 deletions

View File

@ -122,8 +122,8 @@ class CreateContainerTest(BaseAPIIntegrationTest):
self.client.wait(id)
with pytest.raises(docker.errors.APIError) as exc:
self.client.remove_container(id)
err = exc.value.explanation
assert 'You cannot remove ' in err
err = exc.value.explanation.lower()
assert 'stop the container before' in err
self.client.remove_container(id, force=True)
def test_create_container_with_volumes_from(self):

View File

@ -9,7 +9,7 @@ class ErrorsTest(BaseAPIIntegrationTest):
self.client.start(container['Id'])
with pytest.raises(APIError) as cm:
self.client.remove_container(container['Id'])
explanation = cm.value.explanation
assert 'You cannot remove a running container' in explanation
explanation = cm.value.explanation.lower()
assert 'stop the container before' in explanation
assert '{"message":' not in explanation
self.client.remove_container(container['Id'], force=True)