Rename models.get_realm_by_string_id to get_realm.

Finishes the refactoring started in c1bbd8d. The goal of the refactoring is
to change the argument to get_realm from a Realm.domain to a
Realm.string_id. The steps were

* Add a new function, get_realm_by_string_id.

* Change all calls to get_realm to use get_realm_by_string_id instead.

* Remove get_realm.

* (This commit) Rename get_realm_by_string_id to get_realm.

Part of a larger migration to remove the Realm.domain field entirely.
This commit is contained in:
Rishi Gupta
2017-01-03 20:30:48 -08:00
committed by Tim Abbott
parent 0a6d960f37
commit 2b0a7fd0ba
47 changed files with 167 additions and 169 deletions

View File

@@ -23,7 +23,7 @@ from zerver.lib.test_classes import (
ZulipTestCase,
)
from zerver.models import \
get_realm_by_string_id, get_user_profile_by_email, email_to_username, UserProfile, \
get_realm, get_user_profile_by_email, email_to_username, UserProfile, \
PreregistrationUser, Realm
from confirmation.models import Confirmation
@@ -1345,7 +1345,7 @@ class TestLDAP(ZulipTestCase):
with self.settings(AUTH_LDAP_USER_ATTR_MAP=ldap_user_attr_map):
backend = self.backend
email = 'nonexisting@zulip.com'
realm = get_realm_by_string_id('zulip')
realm = get_realm('zulip')
do_deactivate_realm(realm)
with self.assertRaisesRegex(Exception, 'Realm has been deactivated'):
backend.get_or_create_user(email, _LDAPUser())
@@ -1518,7 +1518,7 @@ class TestAdminSetBackends(ZulipTestCase):
result = self.client_patch("/json/realm", {
'authentication_methods': ujson.dumps({u'Email': False, u'Dev': True})})
self.assert_json_success(result)
realm = get_realm_by_string_id('zulip')
realm = get_realm('zulip')
self.assertFalse(password_auth_enabled(realm))
self.assertTrue(dev_auth_enabled(realm))
@@ -1529,7 +1529,7 @@ class TestAdminSetBackends(ZulipTestCase):
result = self.client_patch("/json/realm", {
'authentication_methods': ujson.dumps({u'Email': False, u'Dev': False})})
self.assert_json_error(result, 'At least one authentication method must be enabled.', status_code=403)
realm = get_realm_by_string_id('zulip')
realm = get_realm('zulip')
self.assertTrue(password_auth_enabled(realm))
self.assertTrue(dev_auth_enabled(realm))
@@ -1541,7 +1541,7 @@ class TestAdminSetBackends(ZulipTestCase):
result = self.client_patch("/json/realm", {
'authentication_methods': ujson.dumps({u'Email': False, u'Dev': True, u'GitHub': False})})
self.assert_json_success(result)
realm = get_realm_by_string_id('zulip')
realm = get_realm('zulip')
# Check that unsupported backend is not enabled
self.assertFalse(github_auth_enabled(realm))
self.assertTrue(dev_auth_enabled(realm))