Skip to content

Storage: query string order dependency in 'test_create_bucket_with_string_confict' unit test. #9714

@tseaver

Description

@tseaver

From this CI failure:

______________ TestClient.test_create_bucket_with_string_conflict ______________

self = <tests.unit.test_client.TestClient testMethod=test_create_bucket_with_string_conflict>

    def test_create_bucket_with_string_conflict(self):
        from google.cloud.exceptions import Conflict

        project = "PROJECT"
        user_project = "USER_PROJECT"
        other_project = "OTHER_PROJECT"
        credentials = _make_credentials()
        client = self._make_one(project=project, credentials=credentials)

        bucket_name = "bucket-name"
        URI = "/".join(
            [
                client._connection.API_BASE_URL,
                "storage",
                client._connection.API_VERSION,
                "b?project=%s&userProject=%s" % (other_project, user_project),
            ]
        )
        data = {"error": {"message": "Conflict"}}
        json_expected = {"name": bucket_name}
        http = _make_requests_session(
            [_make_json_response(data, status=http_client.CONFLICT)]
        )
        client._http_internal = http

        with self.assertRaises(Conflict):
            client.create_bucket(
                bucket_name, project=other_project, user_project=user_project
            )

        http.request.assert_called_once_with(
>           method="POST", url=URI, data=mock.ANY, headers=mock.ANY
        )

tests/unit/test_client.py:551:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.nox/unit-3-5/lib/python3.5/site-packages/mock/mock.py:957: in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
.nox/unit-3-5/lib/python3.5/site-packages/mock/mock.py:944: in assert_called_with
    six.raise_from(AssertionError(_error_message(cause)), cause)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

value = None, from_value = None

>   ???
E   Expected: request(data=<ANY>, headers=<ANY>, method='POST', url='https://storage.googleapis.com/storage/v1/b?project=OTHER_PROJECT&userProject=USER_PROJECT')
E   Actual: request(data='{"name": "bucket-name"}', headers={'Content-Type': 'application/json', 'X-Goog-API-Client': 'gcloud-python/1.22.0  gl-python/3.5.3 gax/1.14.3 gccl/1.22.0', 'User-Agent': 'gcloud-python/1.22.0  gl-python/3.5.3 gax/1.14.3 gccl/1.22.0', 'Accept-Encoding': 'gzip'}, method='POST', url='https://storage.googleapis.com/storage/v1/b?userProject=USER_PROJECT&project=OTHER_PROJECT')

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.testingtype: processA process-related concern. May include testing, release, or the like.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions