mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
test_events.py: Add a test for the do_change_realm_alias() function.
This commit is contained in:
committed by
Tim Abbott
parent
fec145fc0c
commit
21dccaedd1
@@ -314,6 +314,10 @@ def apply_events(state, events, user_profile):
|
||||
elif event['type'] == "realm_domains":
|
||||
if event['op'] == 'add':
|
||||
state['realm_domains'].append(event['alias'])
|
||||
elif event['op'] == 'change':
|
||||
for realm_domain in state['realm_domains']:
|
||||
if realm_domain['domain'] == event['alias']['domain']:
|
||||
realm_domain['allow_subdomains'] = event['alias']['allow_subdomains']
|
||||
elif event['op'] == 'remove':
|
||||
state['realm_domains'] = [alias for alias in state['realm_domains'] if alias['domain'] != event['domain']]
|
||||
elif event['type'] == "realm_emoji":
|
||||
|
||||
@@ -59,6 +59,7 @@ from zerver.lib.actions import (
|
||||
do_change_pm_content_in_desktop_notifications,
|
||||
do_change_enable_digest_emails,
|
||||
do_add_realm_alias,
|
||||
do_change_realm_alias,
|
||||
do_remove_realm_alias,
|
||||
)
|
||||
from zerver.lib.events import (
|
||||
@@ -832,10 +833,22 @@ class EventsRegisterTest(ZulipTestCase):
|
||||
|
||||
schema_checker = check_dict([
|
||||
('type', equals('realm_domains')),
|
||||
('op', equals('remove')),
|
||||
('domain', check_string),
|
||||
('op', equals('change')),
|
||||
('alias', check_dict([
|
||||
('domain', equals('zulip.org')),
|
||||
('allow_subdomains', equals(True)),
|
||||
])),
|
||||
])
|
||||
alias = RealmAlias.objects.get(realm=realm, domain='zulip.org')
|
||||
events = self.do_test(lambda: do_change_realm_alias(alias, True))
|
||||
error = schema_checker('events[0]', events[0])
|
||||
self.assert_on_error(error)
|
||||
|
||||
schema_checker = check_dict([
|
||||
('type', equals('realm_domains')),
|
||||
('op', equals('remove')),
|
||||
('domain', equals('zulip.org')),
|
||||
])
|
||||
events = self.do_test(lambda: do_remove_realm_alias(alias))
|
||||
error = schema_checker('events[0]', events[0])
|
||||
self.assert_on_error(error)
|
||||
|
||||
Reference in New Issue
Block a user