def test_banned_user(self):
        """middleware handles user that has been banned in meantime"""
        ban_user(self.user)

        response = self.client.get(self.test_link)
        self.assertEqual(response.status_code, 200)

        response = self.client.get(self.api_link)
        self.assertEqual(response.status_code, 200)
        self.assertIsNone(response.json()['id'])
    def test_banned_user(self):
        """middleware handles user that has been banned in meantime"""
        ban_user(self.user)

        response = self.client.get(self.test_link)
        self.assertEqual(response.status_code, 200)

        response = self.client.get(self.api_link)
        self.assertEqual(response.status_code, 200)
        self.assertIsNone(response.json()['id'])
    def test_banned_staff(self):
        """middleware handles staff user that has been banned in meantime"""
        self.user.is_staff = True
        self.user.save()

        ban_user(self.user)

        response = self.client.get(self.test_link)
        self.assertEqual(response.status_code, 200)

        response = self.client.get(self.api_link)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.json()['id'], self.user.pk)
    def test_banned_staff(self):
        """middleware handles staff user that has been banned in meantime"""
        self.user.is_staff = True
        self.user.save()

        ban_user(self.user)

        response = self.client.get(self.test_link)
        self.assertEqual(response.status_code, 200)

        response = self.client.get(self.api_link)
        self.assertEqual(response.status_code, 200)
        self.assertEqual(response.json()['id'], self.user.pk)
Beispiel #5
0
    def test_ban_user(self):
        """ban_user utility bans user"""
        user = UserModel.objects.create_user('Bob', '*****@*****.**', 'pass123')

        ban = ban_user(user, 'User reason', 'Staff reason')
        self.assertEqual(ban.user_message, 'User reason')
        self.assertEqual(ban.staff_message, 'Staff reason')

        db_ban = get_user_ban(user)
        self.assertEqual(ban.pk, db_ban.ban_id)
    def test_ban_user(self):
        """ban_user utility bans user"""
        user = UserModel.objects.create_user('Bob', '*****@*****.**', 'pass123')

        ban = ban_user(user, 'User reason', 'Staff reason')
        self.assertEqual(ban.user_message, 'User reason')
        self.assertEqual(ban.staff_message, 'Staff reason')

        db_ban = get_user_ban(user)
        self.assertEqual(ban.pk, db_ban.ban_id)
Beispiel #7
0
    def test_ban_user(self):
        """ban_user bans user"""
        User = get_user_model()
        user = User.objects.create_user("Bob", "*****@*****.**", "pass123")

        ban = ban_user(user, "User reason", "Staff reason")
        self.assertEqual(ban.user_message, "User reason")
        self.assertEqual(ban.staff_message, "Staff reason")

        db_ban = get_user_ban(user)
        self.assertEqual(ban.pk, db_ban.ban_id)
Beispiel #8
0
 def ban_user(self):
     ban_user(self.user,
              user_message=self.cleaned_data['user_message'],
              staff_message=self.cleaned_data['staff_message'],
              expires_on=self.cleaned_data['expires_on'])