comparison antispam/tests/test_views.py @ 1215:4bb5ea74164b modernize

Add unit tests for antispam views.
author Brian Neal <bgneal@gmail.com>
date Wed, 12 Feb 2025 19:02:27 -0600
parents
children 42fef17a89a4
comparison
equal deleted inserted replaced
1214:9a011e2de2f6 1215:4bb5ea74164b
1 """
2 Unit tests for the antispam application views.
3
4 """
5 import datetime
6 import json
7
8 from django.test import TestCase
9 from django.core.urlresolvers import reverse
10 from django.contrib.auth.models import User
11
12
13 class SuspendedViewTestCase(TestCase):
14 def setUp(self):
15 self.url = reverse('antispam-suspended')
16
17 def test_suspended_user_is_active(self):
18 self.user = User.objects.create_user(
19 username='pj', email='pj@example.com', password='top_secret')
20 self.client.login(username='pj', password='top_secret')
21 self.assertTrue(self.user.is_active)
22 response = self.client.get(self.url)
23 self.assertEqual(response.status_code, 200)
24
25 def test_suspended_user_is_not_active(self):
26 url = reverse('antispam-suspended')
27 response = self.client.get(self.url)
28 self.assertEqual(response.status_code, 200)