From 4dc62f962bc3bec8419ee72fbf752a064cd5ce9e Mon Sep 17 00:00:00 2001 From: shanukun Date: Sun, 7 Mar 2021 10:30:29 +0530 Subject: [PATCH] refactor: Make acting_user a mandatory kwarg for do_set_realm_authentication_methods. --- docs/tutorials/new-feature-tutorial.md | 4 +++- zerver/lib/actions.py | 2 +- zerver/tests/test_events.py | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/tutorials/new-feature-tutorial.md b/docs/tutorials/new-feature-tutorial.md index 7d68723ca5..94ca645890 100644 --- a/docs/tutorials/new-feature-tutorial.md +++ b/docs/tutorials/new-feature-tutorial.md @@ -321,7 +321,9 @@ field and send an event. For example: # zerver/lib/actions.py - def do_set_realm_authentication_methods(realm: Realm, authentication_methods: Dict[str, bool]) -> None: + def do_set_realm_authentication_methods( + realm: Realm, authentication_methods: Dict[str, bool], *, acting_user: Optional[UserProfile] + ) -> None: for key, value in list(authentication_methods.items()): index = getattr(realm.authentication_methods, key).number realm.authentication_methods.set_bit(index, int(value)) diff --git a/zerver/lib/actions.py b/zerver/lib/actions.py index c74a7dbf90..0e8b6b0cc1 100644 --- a/zerver/lib/actions.py +++ b/zerver/lib/actions.py @@ -824,7 +824,7 @@ def do_set_realm_property( def do_set_realm_authentication_methods( - realm: Realm, authentication_methods: Dict[str, bool], acting_user: Optional[UserProfile] = None + realm: Realm, authentication_methods: Dict[str, bool], *, acting_user: Optional[UserProfile] ) -> None: old_value = realm.authentication_methods_dict() for key, value in list(authentication_methods.items()): diff --git a/zerver/tests/test_events.py b/zerver/tests/test_events.py index 3737753267..a47b1b07e6 100644 --- a/zerver/tests/test_events.py +++ b/zerver/tests/test_events.py @@ -1068,7 +1068,7 @@ class NormalActionsTest(BaseAction): with fake_backends(): events = self.verify_action( lambda: do_set_realm_authentication_methods( - self.user_profile.realm, auth_method_dict + self.user_profile.realm, auth_method_dict, acting_user=None ) )