mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
Use stream ids in various tests.
This commit prepares us to introduce a StreamLite class. For these tests, we don't care about the actual contents of the Stream, just the right stream is there.
This commit is contained in:
@@ -118,12 +118,12 @@ class TestRealmAuditLog(ZulipTestCase):
|
||||
subscription_creation_logs = RealmAuditLog.objects.filter(event_type='subscription_created',
|
||||
event_time__gte=now)
|
||||
self.assertEqual(subscription_creation_logs.count(), 1)
|
||||
self.assertEqual(subscription_creation_logs[0].modified_stream, stream[0])
|
||||
self.assertEqual(subscription_creation_logs[0].modified_stream.id, stream[0].id)
|
||||
self.assertEqual(subscription_creation_logs[0].modified_user, user[0])
|
||||
|
||||
bulk_remove_subscriptions(user, stream)
|
||||
subscription_deactivation_logs = RealmAuditLog.objects.filter(event_type='subscription_deactivated',
|
||||
event_time__gte=now)
|
||||
self.assertEqual(subscription_deactivation_logs.count(), 1)
|
||||
self.assertEqual(subscription_deactivation_logs[0].modified_stream, stream[0])
|
||||
self.assertEqual(subscription_deactivation_logs[0].modified_stream.id, stream[0].id)
|
||||
self.assertEqual(subscription_deactivation_logs[0].modified_user, user[0])
|
||||
|
||||
@@ -353,7 +353,7 @@ class HomeTest(ZulipTestCase):
|
||||
# type: () -> None
|
||||
email = self.example_email("hamlet")
|
||||
realm = get_realm('zulip')
|
||||
realm.notifications_stream = get_stream('Denmark', realm)
|
||||
realm.notifications_stream_id = get_stream('Denmark', realm).id
|
||||
realm.save()
|
||||
self.login(email)
|
||||
result = self._get_home_page()
|
||||
|
||||
@@ -888,7 +888,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||
"""
|
||||
user_profile = self.example_user('hamlet')
|
||||
email = user_profile.email
|
||||
user_profile.default_sending_stream = get_stream('Verona', user_profile.realm)
|
||||
user_profile.default_sending_stream_id = get_stream('Verona', user_profile.realm).id
|
||||
user_profile.save()
|
||||
result = self.client_post("/api/v1/messages", {"type": "stream",
|
||||
"client": "test suite",
|
||||
|
||||
@@ -136,7 +136,7 @@ class TestNotifyNewUser(ZulipTestCase):
|
||||
# type: () -> None
|
||||
new_user = self.example_user('cordelia')
|
||||
stream = self.make_stream('announce')
|
||||
new_user.realm.notifications_stream = stream
|
||||
new_user.realm.notifications_stream_id = stream.id
|
||||
new_user.realm.save()
|
||||
new_user = self.example_user('cordelia')
|
||||
notify_new_user(new_user)
|
||||
|
||||
@@ -206,11 +206,11 @@ class RealmTest(ZulipTestCase):
|
||||
# type: () -> None
|
||||
realm = get_realm("zulip")
|
||||
verona = get_stream("verona", realm)
|
||||
realm.notifications_stream = verona
|
||||
realm.notifications_stream_id = verona.id
|
||||
realm.save()
|
||||
|
||||
notifications_stream = realm.get_notifications_stream()
|
||||
self.assertEqual(notifications_stream, verona)
|
||||
self.assertEqual(notifications_stream.id, verona.id)
|
||||
do_deactivate_stream(notifications_stream)
|
||||
self.assertIsNone(realm.get_notifications_stream())
|
||||
|
||||
|
||||
@@ -525,7 +525,7 @@ class InviteUserTest(ZulipTestCase):
|
||||
"""
|
||||
realm = get_realm('zulip')
|
||||
notifications_stream = get_stream('Verona', realm)
|
||||
realm.notifications_stream = notifications_stream
|
||||
realm.notifications_stream_id = notifications_stream.id
|
||||
realm.save()
|
||||
|
||||
self.login(self.example_email("hamlet"))
|
||||
@@ -535,8 +535,8 @@ class InviteUserTest(ZulipTestCase):
|
||||
self.check_sent_emails([invitee])
|
||||
|
||||
prereg_user = get_prereg_user_by_email(invitee)
|
||||
streams = list(prereg_user.streams.all())
|
||||
self.assertTrue(notifications_stream in streams)
|
||||
stream_ids = [stream.id for stream in prereg_user.streams.all()]
|
||||
self.assertTrue(notifications_stream.id in stream_ids)
|
||||
|
||||
def test_invite_user_signup_initial_history(self):
|
||||
# type: () -> None
|
||||
|
||||
@@ -212,18 +212,18 @@ class StreamAdminTest(ZulipTestCase):
|
||||
# type: () -> None
|
||||
stream = self.make_stream('new_stream')
|
||||
do_add_default_stream(stream)
|
||||
self.assertEqual(1, DefaultStream.objects.filter(stream=stream).count())
|
||||
self.assertEqual(1, DefaultStream.objects.filter(stream_id=stream.id).count())
|
||||
do_deactivate_stream(stream)
|
||||
self.assertEqual(0, DefaultStream.objects.filter(stream=stream).count())
|
||||
self.assertEqual(0, DefaultStream.objects.filter(stream_id=stream.id).count())
|
||||
|
||||
def test_vacate_private_stream_removes_default_stream(self):
|
||||
# type: () -> None
|
||||
stream = self.make_stream('new_stream', invite_only=True)
|
||||
self.subscribe(self.example_user("hamlet"), stream.name)
|
||||
do_add_default_stream(stream)
|
||||
self.assertEqual(1, DefaultStream.objects.filter(stream=stream).count())
|
||||
self.assertEqual(1, DefaultStream.objects.filter(stream_id=stream.id).count())
|
||||
self.unsubscribe(self.example_user("hamlet"), stream.name)
|
||||
self.assertEqual(0, DefaultStream.objects.filter(stream=stream).count())
|
||||
self.assertEqual(0, DefaultStream.objects.filter(stream_id=stream.id).count())
|
||||
# Fetch stream again from database.
|
||||
stream = Stream.objects.get(id=stream.id)
|
||||
self.assertTrue(stream.deactivated)
|
||||
@@ -1392,7 +1392,7 @@ class SubscriptionAPITest(ZulipTestCase):
|
||||
'announce': 'true',
|
||||
}
|
||||
notifications_stream = get_stream(self.streams[0], self.test_realm)
|
||||
self.test_realm.notifications_stream = notifications_stream
|
||||
self.test_realm.notifications_stream_id = notifications_stream.id
|
||||
self.test_realm.save()
|
||||
|
||||
# Delete the UserProfile from the cache so the realm change will be
|
||||
@@ -1435,7 +1435,7 @@ class SubscriptionAPITest(ZulipTestCase):
|
||||
invite_streams = self.make_random_stream_names([current_stream])[:1]
|
||||
|
||||
notifications_stream = get_stream(current_stream, self.test_realm)
|
||||
self.test_realm.notifications_stream = notifications_stream
|
||||
self.test_realm.notifications_stream_id = notifications_stream.id
|
||||
self.test_realm.save()
|
||||
|
||||
# Delete the UserProfile from the cache so the realm change will be
|
||||
@@ -1508,7 +1508,7 @@ class SubscriptionAPITest(ZulipTestCase):
|
||||
|
||||
current_stream = self.get_streams(invitee, self.test_realm)[0]
|
||||
notifications_stream = get_stream(current_stream, self.test_realm)
|
||||
self.test_realm.notifications_stream = notifications_stream
|
||||
self.test_realm.notifications_stream_id = notifications_stream.id
|
||||
self.test_realm.save()
|
||||
|
||||
invite_streams = ['strange ) \\ test']
|
||||
@@ -2690,11 +2690,11 @@ class AccessStreamTest(ZulipTestCase):
|
||||
|
||||
# Hamlet can access the private stream
|
||||
(stream_ret, rec_ret, sub_ret) = access_stream_by_id(hamlet, stream.id)
|
||||
self.assertEqual(stream, stream_ret)
|
||||
self.assertEqual(stream.id, stream_ret.id)
|
||||
self.assertEqual(sub_ret.recipient, rec_ret)
|
||||
self.assertEqual(sub_ret.recipient.type_id, stream.id)
|
||||
(stream_ret2, rec_ret2, sub_ret2) = access_stream_by_name(hamlet, stream.name)
|
||||
self.assertEqual(stream_ret, stream_ret2)
|
||||
self.assertEqual(stream_ret.id, stream_ret2.id)
|
||||
self.assertEqual(sub_ret, sub_ret2)
|
||||
self.assertEqual(rec_ret, rec_ret2)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user