Replace naive datetimes with aware ones

This commit is contained in:
Joel Bradshaw
2020-11-27 16:24:53 -08:00
parent 1df5b2d481
commit d8b2afff3d
8 changed files with 22 additions and 19 deletions

View File

@ -1,5 +1,6 @@
''' testing models '''
import datetime
from django.utils import timezone
from django.test import TestCase
from bookwyrm import models
@ -77,29 +78,29 @@ class ImportJob(TestCase):
def test_date_added(self):
''' converts to the local shelf typology '''
expected = datetime.datetime(2019, 4, 9, 0, 0)
expected = datetime.datetime(2019, 4, 9, 0, 0, tzinfo=timezone.utc)
item = models.ImportItem.objects.get(index=1)
self.assertEqual(item.date_added, expected)
def test_date_read(self):
''' converts to the local shelf typology '''
expected = datetime.datetime(2019, 4, 12, 0, 0)
expected = datetime.datetime(2019, 4, 12, 0, 0, tzinfo=timezone.utc)
item = models.ImportItem.objects.get(index=2)
self.assertEqual(item.date_read, expected)
def test_currently_reading_reads(self):
expected = [models.ReadThrough(
start_date=datetime.datetime(2019, 4, 9, 0, 0))]
start_date=datetime.datetime(2019, 4, 9, 0, 0, tzinfo=timezone.utc))]
actual = models.ImportItem.objects.get(index=1)
self.assertEqual(actual.reads[0].start_date, expected[0].start_date)
self.assertEqual(actual.reads[0].finish_date, expected[0].finish_date)
def test_read_reads(self):
actual = models.ImportItem.objects.get(index=2)
self.assertEqual(actual.reads[0].start_date, datetime.datetime(2019, 4, 9, 0, 0))
self.assertEqual(actual.reads[0].finish_date, datetime.datetime(2019, 4, 12, 0, 0))
self.assertEqual(actual.reads[0].start_date, datetime.datetime(2019, 4, 9, 0, 0, tzinfo=timezone.utc))
self.assertEqual(actual.reads[0].finish_date, datetime.datetime(2019, 4, 12, 0, 0, tzinfo=timezone.utc))
def test_unread_reads(self):
expected = []