2021-04-16 17:47:52 -07:00
|
|
|
from django.test import TestCase
|
|
|
|
from django.contrib.auth.models import User
|
|
|
|
from django.urls import reverse
|
|
|
|
|
|
|
|
|
|
|
|
class TestLogOutViewTestCase(TestCase):
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
user_a = User.objects.create(username='user_a')
|
|
|
|
user_a.set_password('password_user_a')
|
|
|
|
user_a.save()
|
|
|
|
|
2021-04-21 13:27:55 -07:00
|
|
|
def test_log_out_view_get(self):
|
|
|
|
self.client.login(username='user_a', password='password_user_a')
|
|
|
|
response = self.client.get(reverse('accounts:logout'))
|
|
|
|
self.assertEquals(response.status_code, 200)
|
|
|
|
self.assertTemplateUsed(response, 'confirmation.html')
|
|
|
|
self.assertEquals(response.request['PATH_INFO'], '/accounts/logout/')
|
|
|
|
|
2021-04-16 17:47:52 -07:00
|
|
|
def test_log_out_view(self):
|
|
|
|
self.client.login(username='user_a', password='password_user_a')
|
|
|
|
response = self.client.post(reverse('accounts:logout'), follow=True)
|
|
|
|
self.assertEquals(response.status_code, 200)
|
2021-04-18 16:27:45 -07:00
|
|
|
self.assertTrue("Successfully Logged Out" in response.content.decode('utf-8'))
|
2021-04-16 17:47:52 -07:00
|
|
|
self.assertTemplateUsed(response, 'audio/index.html')
|
2021-04-18 14:29:31 -07:00
|
|
|
self.assertEquals(response.request['PATH_INFO'], '/')
|
2021-04-16 17:47:52 -07:00
|
|
|
|
|
|
|
def test_log_out_view_no_login(self):
|
|
|
|
response = self.client.post(reverse('accounts:logout'), follow=True)
|
|
|
|
self.assertEquals(response.status_code, 200)
|
2021-04-18 16:27:45 -07:00
|
|
|
self.assertFalse("Successfully Logged Out" in response.content.decode('utf-8'))
|
2021-04-16 17:47:52 -07:00
|
|
|
self.assertTemplateUsed(response, 'audio/index.html')
|
2021-04-18 14:29:31 -07:00
|
|
|
self.assertEquals(response.request['PATH_INFO'], '/')
|