示例#1
0
    def test_get_all_permissions_from_group_1(self):
        """
        Tests, that get_all_permissions looks in the permissions of the group with
        pk=1
        """
        anonymous = AnonymousUser()

        with patch('openslides.users.auth.Permission') as mock_permission:
            anonymous.get_all_permissions()

        mock_permission.objects.filter.assert_called_once_with(group__pk=1)
示例#2
0
    def test_get_all_permissions_from_group_1(self):
        """
        Tests, that get_all_permissions looks in the permissions of the group with
        pk=1
        """
        anonymous = AnonymousUser()

        with patch("openslides.users.auth.Permission") as mock_permission:
            anonymous.get_all_permissions()

        mock_permission.objects.filter.assert_called_once_with(group__pk=1)
示例#3
0
    def test_has_perm_in_list(self):
        anonymous = AnonymousUser()
        anonymous.get_all_permissions = MagicMock(return_value=('p1', 'p2'))

        self.assertTrue(
            anonymous.has_perm('p1'),
            "has_perm() should return True when the user has the permission")
示例#4
0
    def test_has_perm_not_in_list(self):
        anonymous = AnonymousUser()
        anonymous.get_all_permissions = MagicMock(return_value=("p1", "p2"))

        self.assertFalse(
            anonymous.has_perm("p3"), "has_perm() should return False when the user has not the permission"
        )
示例#5
0
    def test_has_module_perms_not_in_list(self):
        anonymous = AnonymousUser()
        anonymous.get_all_permissions = MagicMock(return_value=("test_otherapp.perm",))

        self.assertFalse(
            anonymous.has_module_perms("test_app"),
            "has_module_perms() should return False when the user does not have " "the permission test_app.perm",
        )
示例#6
0
    def test_has_module_perms_in_list(self):
        anonymous = AnonymousUser()
        anonymous.get_all_permissions = MagicMock(return_value=("test_app.perm",))

        self.assertTrue(
            anonymous.has_module_perms("test_app"),
            "has_module_perms() should return True when the user has the " "permission test_app.perm",
        )
示例#7
0
    def test_has_module_perms_not_in_list(self):
        anonymous = AnonymousUser()
        anonymous.get_all_permissions = MagicMock(
            return_value=('test_otherapp.perm', ))

        self.assertFalse(
            anonymous.has_module_perms('test_app'),
            "has_module_perms() should return False when the user does not have "
            "the permission test_app.perm")
示例#8
0
    def test_has_module_perms_in_list(self):
        anonymous = AnonymousUser()
        anonymous.get_all_permissions = MagicMock(
            return_value=('test_app.perm', ))

        self.assertTrue(
            anonymous.has_module_perms('test_app'),
            "has_module_perms() should return True when the user has the "
            "permission test_app.perm")