From a1f8a179863e86a48157f4ab85921349af3a30be Mon Sep 17 00:00:00 2001 From: Gorka Eguileor Date: Tue, 24 Jan 2017 16:53:31 +0100 Subject: [PATCH] Fix test_auth_with_keystone_v3 test Test is subject to spurious errors due to an incorrect data check. The check is assuming that a call to json.dumps with different dicts will always generate the same string, which is incorrect. This patch tests the JSON data that is sent in the request on its own based on converting the passed JSON string to a dict and comparing expected and actual dicts instead of strings. TrivialFix Closes-Bug: #1658704 Change-Id: I386cfee2e2c1dc2971d8a760b485505a90f6f120 --- cinderclient/tests/unit/test_http.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cinderclient/tests/unit/test_http.py b/cinderclient/tests/unit/test_http.py index 1336a0300..dca0c35d0 100644 --- a/cinderclient/tests/unit/test_http.py +++ b/cinderclient/tests/unit/test_http.py @@ -331,12 +331,18 @@ class ClientTest(utils.TestCase): } } } + + # Check data, we cannot do it on the call because the JSON + # dictionary to string can generated different strings. + actual_data = mock_201_request.call_args[1]['data'] + self.assertDictEqual(data, json.loads(actual_data)) + mock_201_request.assert_called_with( "POST", "http://example.com:5000/v3/auth/tokens", headers=headers, allow_redirects=True, - data=json.dumps(data), + data=actual_data, **self.TEST_REQUEST_BASE) test_auth_call()