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
This commit is contained in:
Gorka Eguileor
2017-01-24 16:53:31 +01:00
parent fe6803c88b
commit a1f8a17986

View File

@@ -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()