From 3fcafee74f48c47962b21efe1f95d078cc77da4e Mon Sep 17 00:00:00 2001 From: Martin Kopec Date: Thu, 3 May 2018 11:56:48 +0000 Subject: [PATCH] Fix flaky unit test A unit test was manipulating with a constant which led to having unexpected fake data and to a failure during unit testing. The test now copies the contants and changes it only in the scope of that test. Change-Id: Icbafb3906ca11d9a17bd34d144a839051373b483 --- config_tempest/tests/services/test_identity.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/config_tempest/tests/services/test_identity.py b/config_tempest/tests/services/test_identity.py index 625c7520..4b18790b 100644 --- a/config_tempest/tests/services/test_identity.py +++ b/config_tempest/tests/services/test_identity.py @@ -73,11 +73,12 @@ class TestIdentityService(BaseServiceTest): self.FAKE_IDENTITY_VERSION) expected_resp = ['v2.1', 'v3.8'] # add not deprecated v2 version to FAKE_IDENTITY_VERSIONS - v2 = {'status': 'stable', 'id': 'v2.1'} - self.FAKE_IDENTITY_VERSIONS['versions']['values'].append(v2) + v2 = [{'status': 'stable', 'id': 'v2.1'}] + versions = self.FAKE_IDENTITY_VERSIONS['versions']['values'] + v2 + fake_versions = {'versions': {'values': versions}} self._test_deserialize_versions(self.Service, expected_resp, - self.FAKE_IDENTITY_VERSIONS) + fake_versions) @mock.patch('config_tempest.services.identity' '.IdentityService.get_versions')