mybuddy/reports/tests/tests_views.py

75 lines
2.6 KiB
Python
Raw Normal View History

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 import get_user_model
2017-10-25 14:48:33 +00:00
from django.core.management import call_command
2022-05-28 02:56:38 +00:00
from faker import Faker
2017-10-25 14:48:33 +00:00
from core import models
class ViewsTestCase(TestCase):
@classmethod
def setUpClass(cls):
super(ViewsTestCase, cls).setUpClass()
2022-05-28 02:56:38 +00:00
fake = Faker()
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
}
cls.user = get_user_model().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
page = self.c.get(base_url)
self.assertEqual(page.status_code, 200)
page = self.c.get("{}/bmi/bmi/".format(base_url))
2022-03-03 03:00:06 +00:00
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))
self.assertEqual(page.status_code, 200)
page = self.c.get("{}/head-circumference/head-circumference/".format(base_url))
2017-10-25 14:48:33 +00:00
self.assertEqual(page.status_code, 200)
page = self.c.get("{}/height/height/".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
page = self.c.get("{}/pumping/amounts/".format(base_url))
2017-11-10 12:20:34 +00:00
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)
2023-01-02 23:35:23 +00:00
page = self.c.get("{}/temperature/temperature/".format(base_url))
self.assertEqual(page.status_code, 200)
page = self.c.get("{}/tummy-time/duration/".format(base_url))
self.assertEqual(page.status_code, 200)
page = self.c.get("{}/weight/weight/".format(base_url))
self.assertEqual(page.status_code, 200)