mirror of https://github.com/zulip/zulip.git
Add tests for deactivate_stream_backend
deactivate_stream_backend was untested now we test 1) That subscriptions are removed 2) That the realm admin is required (imported from commit eedb1c4fc0e363df58721302e9f8fbedf78389a9)
This commit is contained in:
parent
1246ee3acd
commit
9d7ee674c6
|
@ -550,6 +550,37 @@ class StreamAdminTest(AuthedTestCase):
|
|||
stream = Stream.objects.get(name='public_stream', realm=realm)
|
||||
self.assertTrue(stream.invite_only)
|
||||
|
||||
def test_deactivate_stream_backend(self):
|
||||
email = 'hamlet@zulip.com'
|
||||
self.login(email)
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
realm = user_profile.realm
|
||||
stream, _ = create_stream_if_needed(realm, 'new_stream')
|
||||
do_add_subscription(user_profile, stream, no_log=True)
|
||||
assign_perm('administer', user_profile, realm)
|
||||
|
||||
result = self.client.delete('/json/streams/new_stream')
|
||||
self.assert_json_success(result)
|
||||
subscription_exists = Subscription.objects.filter(
|
||||
user_profile=user_profile,
|
||||
recipient__type_id=stream.id,
|
||||
recipient__type=Recipient.STREAM,
|
||||
active=True,
|
||||
).exists()
|
||||
self.assertFalse(subscription_exists)
|
||||
|
||||
def test_deactivate_stream_backend_requires_realm_admin(self):
|
||||
email = 'hamlet@zulip.com'
|
||||
self.login(email)
|
||||
user_profile = get_user_profile_by_email(email)
|
||||
realm = user_profile.realm
|
||||
stream, _ = create_stream_if_needed(realm, 'new_stream')
|
||||
do_add_subscription(user_profile, stream, no_log=True)
|
||||
|
||||
result = self.client.delete('/json/streams/new_stream')
|
||||
self.assert_json_error(result, 'Must be a realm administrator')
|
||||
|
||||
|
||||
class PermissionTest(TestCase):
|
||||
def test_get_admin_users(self):
|
||||
user_profile = get_user_profile_by_email('hamlet@zulip.com')
|
||||
|
|
Loading…
Reference in New Issue