mirror of https://github.com/zulip/zulip.git
test_realm: Fix a flaky test due to random message populated.
The messages populated in the test database are random in nature, so there is a possibility of any number of messages in 'new_stream_announcements_stream' in 'test_merge_streams'. Earlier, the test was assuming of exactly one message in that stream. That would result in a flaky behavior. This commit fixes the flaky behavior.
This commit is contained in:
parent
fd335c06eb
commit
20fbba6375
|
@ -542,6 +542,9 @@ class RealmTest(ZulipTestCase):
|
||||||
cordelia = self.example_user("cordelia")
|
cordelia = self.example_user("cordelia")
|
||||||
new_stream_announcements_stream = realm.get_new_stream_announcements_stream()
|
new_stream_announcements_stream = realm.get_new_stream_announcements_stream()
|
||||||
assert new_stream_announcements_stream is not None
|
assert new_stream_announcements_stream is not None
|
||||||
|
new_stream_announcements_stream_messages_count = Message.objects.filter(
|
||||||
|
realm_id=realm.id, recipient=new_stream_announcements_stream.recipient
|
||||||
|
).count()
|
||||||
|
|
||||||
create_stream_if_needed(realm, "Atlantis")
|
create_stream_if_needed(realm, "Atlantis")
|
||||||
self.subscribe(cordelia, "Atlantis")
|
self.subscribe(cordelia, "Atlantis")
|
||||||
|
@ -558,7 +561,7 @@ class RealmTest(ZulipTestCase):
|
||||||
get_stream("Atlantis", realm)
|
get_stream("Atlantis", realm)
|
||||||
|
|
||||||
stats = merge_streams(realm, denmark, new_stream_announcements_stream)
|
stats = merge_streams(realm, denmark, new_stream_announcements_stream)
|
||||||
self.assertEqual(stats, (2, 1, 10))
|
self.assertEqual(stats, (2, new_stream_announcements_stream_messages_count, 10))
|
||||||
self.assertIsNone(realm.get_new_stream_announcements_stream())
|
self.assertIsNone(realm.get_new_stream_announcements_stream())
|
||||||
|
|
||||||
def test_change_signup_announcements_stream(self) -> None:
|
def test_change_signup_announcements_stream(self) -> None:
|
||||||
|
|
Loading…
Reference in New Issue