2022-06-17 13:40:28 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import datetime as dt
|
|
|
|
|
|
|
|
from django.test import TestCase
|
|
|
|
from django.utils import timezone
|
|
|
|
|
|
|
|
from core import models
|
|
|
|
from reports.graphs import sleep_pattern
|
|
|
|
|
|
|
|
|
|
|
|
class SleepPatternTestCase(TestCase):
|
|
|
|
def setUp(self):
|
|
|
|
self.original_tz = timezone.get_current_timezone()
|
|
|
|
self.tz = dt.timezone(dt.timedelta(days=-1, hours=1))
|
|
|
|
timezone.activate(self.tz)
|
|
|
|
|
|
|
|
def tearDown(self):
|
|
|
|
timezone.activate(self.original_tz)
|
|
|
|
|
|
|
|
def test_sleep_pattern(self):
|
|
|
|
c = models.Child(birth_date=dt.datetime.now())
|
|
|
|
c.save()
|
|
|
|
|
|
|
|
models.Sleep.objects.create(
|
|
|
|
child=c,
|
2024-01-14 04:22:08 +00:00
|
|
|
start=dt.datetime(2000, 1, 1, 0, 0, tzinfo=dt.timezone.utc),
|
|
|
|
end=dt.datetime(2000, 1, 1, 0, 1, tzinfo=dt.timezone.utc),
|
2022-06-17 13:40:28 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
sleep_pattern(models.Sleep.objects.order_by("start"))
|