Mercurial > public > sg101
changeset 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 | 9a011e2de2f6 |
children | 42fef17a89a4 |
files | antispam/tests/test_views.py |
diffstat | 1 files changed, 28 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/antispam/tests/test_views.py Wed Feb 12 19:02:27 2025 -0600 @@ -0,0 +1,28 @@ +""" +Unit tests for the antispam application views. + +""" +import datetime +import json + +from django.test import TestCase +from django.core.urlresolvers import reverse +from django.contrib.auth.models import User + + +class SuspendedViewTestCase(TestCase): + def setUp(self): + self.url = reverse('antispam-suspended') + + def test_suspended_user_is_active(self): + self.user = User.objects.create_user( + username='pj', email='pj@example.com', password='top_secret') + self.client.login(username='pj', password='top_secret') + self.assertTrue(self.user.is_active) + response = self.client.get(self.url) + self.assertEqual(response.status_code, 200) + + def test_suspended_user_is_not_active(self): + url = reverse('antispam-suspended') + response = self.client.get(self.url) + self.assertEqual(response.status_code, 200)