Add reports tests.

This commit is contained in:
Christopher Charbonneau Wells 2017-10-25 10:48:33 -04:00
parent 789054cfb6
commit 72a75feea9
2 changed files with 49 additions and 0 deletions

View File

View File

@ -0,0 +1,49 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.test import TestCase
from django.test import Client as HttpClient
from django.contrib.auth.models import User
from django.core.management import call_command
from faker import Factory
from core import models
class ViewsTestCase(TestCase):
@classmethod
def setUpClass(cls):
super(ViewsTestCase, cls).setUpClass()
fake = Factory.create()
call_command('migrate', verbosity=0)
call_command('fake', verbosity=0)
cls.c = HttpClient()
fake_user = fake.simple_profile()
cls.credentials = {
'username': fake_user['username'],
'password': fake.password()
}
cls.user = User.objects.create_user(
is_superuser=True, **cls.credentials)
cls.c.login(**cls.credentials)
def test_graph_child_views(self):
child = models.Child.objects.first()
base_url = '/children/{}/reports'.format(child.slug)
page = self.c.get('{}/changes/lifetimes/'.format(base_url))
self.assertEqual(page.status_code, 200)
page = self.c.get('{}/changes/types/'.format(base_url))
self.assertEqual(page.status_code, 200)
page = self.c.get('{}/sleep/pattern/'.format(base_url))
self.assertEqual(page.status_code, 200)
page = self.c.get('{}/sleep/totals/'.format(base_url))
self.assertEqual(page.status_code, 200)
page = self.c.get('{}/timeline/'.format(base_url))
self.assertEqual(page.status_code, 200)