Reverting to TestCase client

This commit is contained in:
Sam Splunks 2024-12-06 10:07:08 +00:00
parent f7ca446bc9
commit 93f6123545

View File

@ -64,20 +64,19 @@ class KBTests(TestCase):
self.assertContains(response, '1 open tickets') self.assertContains(response, '1 open tickets')
def test_kb_vote(self): def test_kb_vote(self):
client = Client(enforce_csrf_checks=True) self.client.login(username=self.user.get_username(),
client.login(username=self.user.get_username(),
password='password') password='password')
response = client.post( response = self.client.post(
reverse('helpdesk:kb_vote', args=(self.kbitem1.pk, "up")), params={}) reverse('helpdesk:kb_vote', args=(self.kbitem1.pk, "up")), params={})
cat_url = reverse('helpdesk:kb_category', cat_url = reverse('helpdesk:kb_category',
args=("test_cat",)) + "?kbitem=1" args=("test_cat",)) + "?kbitem=1"
self.assertRedirects(response, cat_url) self.assertRedirects(response, cat_url)
response = client.get(cat_url) response = self.client.get(cat_url)
self.assertContains(response, '1 people found this answer useful of 1') self.assertContains(response, '1 people found this answer useful of 1')
response = client.post( response = self.client.post(
reverse('helpdesk:kb_vote', args=(self.kbitem1.pk, "down")), params={}) reverse('helpdesk:kb_vote', args=(self.kbitem1.pk, "down")), params={})
self.assertRedirects(response, cat_url) self.assertRedirects(response, cat_url)
response = client.get(cat_url) response = self.client.get(cat_url)
self.assertContains(response, '0 people found this answer useful of 1') self.assertContains(response, '0 people found this answer useful of 1')
def test_kb_category_iframe(self): def test_kb_category_iframe(self):