Add tests for new realm properties, fix revealed typo.

(imported from commit 49ffcf7edc64c2dbc3cf41ed64222390072c2e88)
This commit is contained in:
David Roe
2015-08-20 14:31:01 -07:00
committed by Tim Abbott
parent 086d8eee22
commit 8cb7b759c6
2 changed files with 43 additions and 1 deletions

View File

@@ -212,7 +212,7 @@ def do_set_realm_restricted_to_domain(realm, restricted):
event = dict( event = dict(
type="realm", type="realm",
op="update", op="update",
property='restricted_restricted_to_domain', property='restricted_to_domain',
value=restricted, value=restricted,
) )
send_event(event, active_user_ids(realm)) send_event(event, active_user_ids(realm))

View File

@@ -29,6 +29,9 @@ from zerver.lib.actions import (
do_rename_stream, do_rename_stream,
do_set_muted_topics, do_set_muted_topics,
do_set_realm_name, do_set_realm_name,
do_set_realm_restricted_to_domain,
do_set_realm_invite_required,
do_set_realm_invite_by_admins_only,
do_update_message, do_update_message,
do_update_pointer, do_update_pointer,
fetch_initial_state_data, fetch_initial_state_data,
@@ -377,6 +380,45 @@ class EventsRegisterTest(AuthedTestCase):
error = schema_checker('events[0]', events[0]) error = schema_checker('events[0]', events[0])
self.assert_on_error(error) self.assert_on_error(error)
def test_change_realm_restricted_to_domain(self):
schema_checker = check_dict([
('type', equals('realm')),
('op', equals('update')),
('property', equals('restricted_to_domain')),
('value', check_bool),
])
# The first True is probably a noop, then we get transitions in both directions.
for restricted_to_domain in (True, False, True):
events = self.do_test(lambda: do_set_realm_restricted_to_domain(self.user_profile.realm, restricted_to_domain))
error = schema_checker('events[0]', events[0])
self.assert_on_error(error)
def test_change_realm_invite_required(self):
schema_checker = check_dict([
('type', equals('realm')),
('op', equals('update')),
('property', equals('invite_required')),
('value', check_bool),
])
# The first False is probably a noop, then we get transitions in both directions.
for invite_required in (False, True, False):
events = self.do_test(lambda: do_set_realm_invite_required(self.user_profile.realm, invite_required))
error = schema_checker('events[0]', events[0])
self.assert_on_error(error)
def test_change_realm_invite_by_admins_only(self):
schema_checker = check_dict([
('type', equals('realm')),
('op', equals('update')),
('property', equals('invite_by_admins_only')),
('value', check_bool),
])
# The first False is probably a noop, then we get transitions in both directions.
for invite_by_admins_only in (False, True, False):
events = self.do_test(lambda: do_set_realm_invite_by_admins_only(self.user_profile.realm, invite_by_admins_only))
error = schema_checker('events[0]', events[0])
self.assert_on_error(error)
def test_change_is_admin(self): def test_change_is_admin(self):
schema_checker = check_dict([ schema_checker = check_dict([
('type', equals('realm_user')), ('type', equals('realm_user')),