Making test independent of message ordering.

This commit is contained in:
Charlton Austin 2017-01-23 13:36:11 -05:00
parent 28813159e5
commit 7854bf6b3a

View file

@ -4739,10 +4739,16 @@ class TestSuperUserManagement(ApiTestCase):
json = self.getJsonResponse(GlobalUserMessages)
self.assertEquals(len(json['messages']), 3)
self.assertEquals(json['messages'][2]["content"], "new message")
self.assertEquals(json['messages'][2]["severity"], "info")
self.assertEquals(json['messages'][2]["media_type"], "text/plain")
has_matching_message = False
for message in json["messages"]:
new_message_match = message["content"] == "new message"
severity_match = message["severity"] == "info"
media_type_match = message["media_type"] == "text/plain"
if new_message_match and severity_match and media_type_match:
has_matching_message = True
break
self.assertTrue(has_matching_message, "Could not find matching message in: " + str(json["messages"]))
self.assertNotEqual(json['messages'][0]["content"], json['messages'][2]["content"])
self.assertTrue(json['messages'][2]["uuid"])