From 7854bf6b3a61f979f3de4f1cc4254df729490042 Mon Sep 17 00:00:00 2001 From: Charlton Austin Date: Mon, 23 Jan 2017 13:36:11 -0500 Subject: [PATCH] Making test independent of message ordering. --- test/test_api_usage.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/test/test_api_usage.py b/test/test_api_usage.py index 500d0d424..35c322ee3 100644 --- a/test/test_api_usage.py +++ b/test/test_api_usage.py @@ -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"])