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.
This commit is contained in:
Sahil Batra 2021-10-05 13:03:35 +05:30 committed by Tim Abbott
parent c07b8e9b44
commit a63385f47f
1 changed files with 16 additions and 0 deletions

View File

@ -1261,6 +1261,14 @@ Output:
) )
member_user.save() 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) do_set_realm_property(realm, policy, Realm.POLICY_ADMINS_ONLY, acting_user=None)
self.assertTrue(validation_func(owner_user)) self.assertTrue(validation_func(owner_user))
self.assertTrue(validation_func(admin_user)) self.assertTrue(validation_func(admin_user))
@ -1293,6 +1301,14 @@ Output:
self.assertTrue(validation_func(new_member_user)) self.assertTrue(validation_func(new_member_user))
self.assertFalse(validation_func(guest_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( def subscribe_realm_to_manual_license_management_plan(
self, realm: Realm, licenses: int, licenses_at_next_renewal: int, billing_schedule: int self, realm: Realm, licenses: int, licenses_at_next_renewal: int, billing_schedule: int
) -> Tuple[CustomerPlan, LicenseLedger]: ) -> Tuple[CustomerPlan, LicenseLedger]: