stylistic cleanup of import model tests

This commit is contained in:
Mouse Reeve 2020-12-27 13:32:27 -08:00
parent e0d8e49d57
commit 9f74e95b00

View file

@ -54,11 +54,11 @@ class ImportJob(TestCase):
user = models.User.objects.create_user(
'mouse', 'mouse@mouse.mouse', 'mouseword', local=True)
job = models.ImportJob.objects.create(user=user)
models.ImportItem.objects.create(
self.item_1 = models.ImportItem.objects.create(
job=job, index=1, data=currently_reading_data)
models.ImportItem.objects.create(
self.item_2 = models.ImportItem.objects.create(
job=job, index=2, data=read_data)
models.ImportItem.objects.create(
self.item_3 = models.ImportItem.objects.create(
job=job, index=3, data=unknown_read_data)
@ -72,8 +72,7 @@ class ImportJob(TestCase):
def test_shelf(self):
''' converts to the local shelf typology '''
expected = 'reading'
item = models.ImportItem.objects.get(index=1)
self.assertEqual(item.shelf, expected)
self.assertEqual(self.item_1.shelf, expected)
def test_date_added(self):
@ -91,21 +90,26 @@ class ImportJob(TestCase):
def test_currently_reading_reads(self):
''' infer currently reading dates where available '''
expected = [models.ReadThrough(
start_date=datetime.datetime(2019, 4, 9, 0, 0, tzinfo=timezone.utc))]
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, tzinfo=timezone.utc))
self.assertEqual(actual.reads[0].finish_date, datetime.datetime(2019, 4, 12, 0, 0, tzinfo=timezone.utc))
''' infer read dates where available '''
actual = self.item_2
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):
''' handle books with no read dates '''
expected = []
actual = models.ImportItem.objects.get(index=3)
self.assertEqual(actual.reads, expected)