2017-10-25 14:48:33 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
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()
|
2022-02-10 00:00:30 +00:00
|
|
|
call_command("migrate", verbosity=0)
|
|
|
|
call_command("fake", verbosity=0)
|
2017-10-25 14:48:33 +00:00
|
|
|
|
|
|
|
cls.c = HttpClient()
|
|
|
|
|
|
|
|
fake_user = fake.simple_profile()
|
|
|
|
cls.credentials = {
|
2022-02-10 00:00:30 +00:00
|
|
|
"username": fake_user["username"],
|
|
|
|
"password": fake.password(),
|
2017-10-25 14:48:33 +00:00
|
|
|
}
|
2022-02-10 00:00:30 +00:00
|
|
|
cls.user = User.objects.create_user(is_superuser=True, **cls.credentials)
|
2017-10-25 14:48:33 +00:00
|
|
|
|
|
|
|
cls.c.login(**cls.credentials)
|
|
|
|
|
|
|
|
def test_graph_child_views(self):
|
|
|
|
child = models.Child.objects.first()
|
2022-02-10 00:00:30 +00:00
|
|
|
base_url = "/children/{}/reports".format(child.slug)
|
2017-10-25 14:48:33 +00:00
|
|
|
|
2022-02-26 21:23:43 +00:00
|
|
|
page = self.c.get(base_url)
|
|
|
|
self.assertEqual(page.status_code, 200)
|
|
|
|
|
2022-03-03 03:00:06 +00:00
|
|
|
page = self.c.get("{}/breastpump/amounts/".format(base_url))
|
|
|
|
self.assertEqual(page.status_code, 200)
|
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
page = self.c.get("{}/changes/amounts/".format(base_url))
|
2020-01-26 22:12:27 +00:00
|
|
|
self.assertEqual(page.status_code, 200)
|
2022-02-10 00:00:30 +00:00
|
|
|
page = self.c.get("{}/changes/lifetimes/".format(base_url))
|
2017-10-25 14:48:33 +00:00
|
|
|
self.assertEqual(page.status_code, 200)
|
2022-02-10 00:00:30 +00:00
|
|
|
page = self.c.get("{}/changes/types/".format(base_url))
|
2017-10-25 14:48:33 +00:00
|
|
|
self.assertEqual(page.status_code, 200)
|
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
page = self.c.get("{}/feeding/amounts/".format(base_url))
|
2019-05-29 17:05:30 +00:00
|
|
|
self.assertEqual(page.status_code, 200)
|
2022-02-10 00:00:30 +00:00
|
|
|
page = self.c.get("{}/feeding/duration/".format(base_url))
|
2017-11-30 02:28:54 +00:00
|
|
|
self.assertEqual(page.status_code, 200)
|
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
page = self.c.get("{}/sleep/pattern/".format(base_url))
|
2017-10-25 14:48:33 +00:00
|
|
|
self.assertEqual(page.status_code, 200)
|
2022-02-10 00:00:30 +00:00
|
|
|
page = self.c.get("{}/sleep/totals/".format(base_url))
|
2017-10-25 14:48:33 +00:00
|
|
|
self.assertEqual(page.status_code, 200)
|
2017-11-10 12:20:34 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
page = self.c.get("{}/weight/weight/".format(base_url))
|
2017-11-10 12:20:34 +00:00
|
|
|
self.assertEqual(page.status_code, 200)
|
2021-12-29 07:53:36 +00:00
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
page = self.c.get("{}/height/height/".format(base_url))
|
2021-12-29 07:53:36 +00:00
|
|
|
self.assertEqual(page.status_code, 200)
|
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
page = self.c.get("{}/head-circumference/head-circumference/".format(base_url))
|
2021-12-29 07:53:36 +00:00
|
|
|
self.assertEqual(page.status_code, 200)
|
|
|
|
|
2022-02-10 00:00:30 +00:00
|
|
|
page = self.c.get("{}/bmi/bmi/".format(base_url))
|
2021-12-29 07:53:36 +00:00
|
|
|
self.assertEqual(page.status_code, 200)
|