From a63385f47fe190398c62d9e6a9cd3a5979adbea1 Mon Sep 17 00:00:00 2001 From: Sahil Batra Date: Tue, 5 Oct 2021 13:03:35 +0530 Subject: [PATCH] tests: Check all cases in check_has_permission_policies. This commit adds tests for POLICY_EVERYONE and POLICY_NOBODY in check_has_permission_policies test. The original code used these values but these were not covered in test. --- zerver/lib/test_classes.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/zerver/lib/test_classes.py b/zerver/lib/test_classes.py index e67fdc2ade..5745844e04 100644 --- a/zerver/lib/test_classes.py +++ b/zerver/lib/test_classes.py @@ -1261,6 +1261,14 @@ Output: ) member_user.save() + do_set_realm_property(realm, policy, Realm.POLICY_NOBODY, acting_user=None) + self.assertFalse(validation_func(owner_user)) + self.assertFalse(validation_func(admin_user)) + self.assertFalse(validation_func(moderator_user)) + self.assertFalse(validation_func(member_user)) + self.assertFalse(validation_func(new_member_user)) + self.assertFalse(validation_func(guest_user)) + do_set_realm_property(realm, policy, Realm.POLICY_ADMINS_ONLY, acting_user=None) self.assertTrue(validation_func(owner_user)) self.assertTrue(validation_func(admin_user)) @@ -1293,6 +1301,14 @@ Output: self.assertTrue(validation_func(new_member_user)) self.assertFalse(validation_func(guest_user)) + do_set_realm_property(realm, policy, Realm.POLICY_EVERYONE, acting_user=None) + self.assertTrue(validation_func(owner_user)) + self.assertTrue(validation_func(admin_user)) + self.assertTrue(validation_func(moderator_user)) + self.assertTrue(validation_func(member_user)) + self.assertTrue(validation_func(new_member_user)) + self.assertTrue(validation_func(guest_user)) + def subscribe_realm_to_manual_license_management_plan( self, realm: Realm, licenses: int, licenses_at_next_renewal: int, billing_schedule: int ) -> Tuple[CustomerPlan, LicenseLedger]: