def test_at_limit__user_role(self):
        """
        Even if no more admins are allowed, the user role can be set.

        """
        tier = self.create_tier(admin_limit=1)
        self.create_tier_info(tier)
        form = AuthorForm({'role': 'user'}, instance=self.user)
        form.cleaned_data = {'role': 'user'}
        self.assertEqual(form.clean_role(), 'user')
    def test_no_limit(self):
        """
        Admin assignment is allowed if there's no limit.

        """
        tier = self.create_tier(admin_limit=None)
        self.create_tier_info(tier)
        form = AuthorForm({'role': 'admin'}, instance=self.user)
        form.cleaned_data = {'role': 'admin'}
        self.assertEqual(form.clean_role(), 'admin')
Example #3
0
    def test_at_limit__user_role(self):
        """
        Even if no more admins are allowed, the user role can be set.

        """
        tier = self.create_tier(admin_limit=1)
        self.create_tier_info(tier)
        form = AuthorForm({'role': 'user'}, instance=self.user)
        form.cleaned_data = {'role': 'user'}
        self.assertEqual(form.clean_role(), 'user')
Example #4
0
    def test_no_limit(self):
        """
        Admin assignment is allowed if there's no limit.

        """
        tier = self.create_tier(admin_limit=None)
        self.create_tier_info(tier)
        form = AuthorForm({'role': 'admin'}, instance=self.user)
        form.cleaned_data = {'role': 'admin'}
        self.assertEqual(form.clean_role(), 'admin')
    def test_at_limit__already_admin(self):
        """
        Even if no more admins are allowed, anyone who is an admin can stay
        that way (as far as this form is concerned.)

        """
        tier = self.create_tier(admin_limit=1)
        self.create_tier_info(tier)
        form = AuthorForm({'role': 'admin'}, instance=self.user,
                          initial={'role': 'admin'})
        form.cleaned_data = {'role': 'admin'}
        self.assertEqual(form.clean_role(), 'admin')
Example #6
0
    def test_at_limit__already_admin(self):
        """
        Even if no more admins are allowed, anyone who is an admin can stay
        that way (as far as this form is concerned.)

        """
        tier = self.create_tier(admin_limit=1)
        self.create_tier_info(tier)
        form = AuthorForm({'role': 'admin'},
                          instance=self.user,
                          initial={'role': 'admin'})
        form.cleaned_data = {'role': 'admin'}
        self.assertEqual(form.clean_role(), 'admin')