From 1c2479c807cf51b522e26e66e09d545dc347f108 Mon Sep 17 00:00:00 2001 From: Scott Feeney Date: Fri, 6 Sep 2013 23:12:24 -0400 Subject: [PATCH] Fix overly-tight coupling in set_stream_color test The test will fail if a new attribute is added to the structure that gather_subscriptions() returns. It should only be concerned with the subscription's color. (imported from commit fd5bad97bbce2544e0078ee029f54d4e45da9c15) --- zerver/tests.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/zerver/tests.py b/zerver/tests.py index 4e3e77d395..c9b9deaeb6 100644 --- a/zerver/tests.py +++ b/zerver/tests.py @@ -893,9 +893,6 @@ class SubscriptionPropertiesTest(AuthedTestCase): old_subs, _ = gather_subscriptions(get_user_profile_by_email(test_email)) sub = old_subs[0] stream_name = sub['name'] - old_color = sub['color'] - invite_only = sub['invite_only'] - email_address = sub['email_address'] new_color = "#ffffff" # TODO: ensure that this is different from old_color result = self.client.post("/json/subscriptions/property", {"property": "color", @@ -905,14 +902,21 @@ class SubscriptionPropertiesTest(AuthedTestCase): self.assert_json_success(result) new_subs = gather_subscriptions(get_user_profile_by_email(test_email))[0] - sub = {'name': stream_name, 'in_home_view': True, 'color': new_color, - 'invite_only': invite_only, 'notifications': False, - 'email_address': email_address} - self.assertIn(sub, new_subs) + found_sub = None + for sub in new_subs: + if sub['name'] == stream_name: + found_sub = sub + break - new_subs.remove(sub) - sub['color'] = old_color - old_subs.remove(sub) + self.assertIsNotNone(found_sub) + self.assertEqual(found_sub['color'], new_color) + + new_subs.remove(found_sub) + for sub in old_subs: + if sub['name'] == stream_name: + found_sub = sub + break + old_subs.remove(found_sub) self.assertEqual(old_subs, new_subs) def test_set_color_missing_stream_name(self):