test_views.py 856 Bytes
Newer Older
Lukas Burgey's avatar
Lukas Burgey committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27

from .. import test_models
from django.contrib import auth
from django.test import Client
from django.test import TestCase


class ViewTest(TestCase):
    def setUp(self):
        test_models.setup_fixture()

    def tearDown(self):
        test_models.teardown_fixture()


    def test_view(self):
        client = Client()
        user = auth.authenticate(
            username=test_models.TEST_NAME,
            password=test_models.TEST_PASSWORD,
        )
        client.force_login(
            user=user
        )
        response = client.get(
            '/backend/api/state/',
        )
Lukas Burgey's avatar
Lukas Burgey committed
28
29
30
        self.assertTrue('services' in response.json())
        self.assertTrue('user_state' in response.json())
        self.assertTrue('user' in response.json())
Lukas Burgey's avatar
Lukas Burgey committed
31
        self.assertEqual(response.json()['user']['userinfo']['email'], test_models.TEST_EMAIL)