summaryrefslogtreecommitdiff
path: root/app/accounts/tests/test_views.py
blob: 39dcb31a6e3c8745a2ce11320161828b28b04816 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from django.test import Client
from django.test import RequestFactory, TestCase
from mixer.backend.django import mixer

from accounts.models import User
from accounts.views import ProfileView


class ProfileViewTest(TestCase):
    def setUp(self):
        # Every test needs access to the request factory.
        self.factory = RequestFactory()
        self.user = mixer.blend(User, username='tpynchon', password="gravity")

    def test_profile_view(self):
        request = self.factory.get('/settings/')
        request.user = self.user
        response = ProfileView.as_view()(request)
        self.assertEqual(response.status_code, 200)
        response.render()
        html = response.content.decode('utf8')
        self.assertTrue(html.startswith('<!DOCTYPE html>'))
        self.assertIn('<h1>Account Settings</h1>', html)