Fixes default edition ranking test

This commit is contained in:
Mouse Reeve 2021-06-26 09:57:56 -07:00
parent 61785cee66
commit 2fa5fabb7b

View file

@ -43,16 +43,16 @@ class SelfConnector(TestCase):
self.assertEqual(result.year, 1980) self.assertEqual(result.year, 1980)
self.assertEqual(result.connector, self.connector) self.assertEqual(result.connector, self.connector)
def test_search_rank(self): @patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay")
def test_search_rank(self, _):
"""prioritize certain results""" """prioritize certain results"""
author = models.Author.objects.create(name="Anonymous") author = models.Author.objects.create(name="Anonymous")
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
edition = models.Edition.objects.create( edition = models.Edition.objects.create(
title="Edition of Example Work", title="Edition of Example Work",
published_date=datetime.datetime(1980, 5, 10, tzinfo=timezone.utc), published_date=datetime.datetime(1980, 5, 10, tzinfo=timezone.utc),
parent_work=models.Work.objects.create(title=""), parent_work=models.Work.objects.create(title=""),
) )
# author text is rank C # author text is rank B
edition.authors.add(author) edition.authors.add(author)
# series is rank D # series is rank D
@ -80,9 +80,9 @@ class SelfConnector(TestCase):
self.assertEqual(results[1].title, "More Editions") self.assertEqual(results[1].title, "More Editions")
self.assertEqual(results[2].title, "Edition of Example Work") self.assertEqual(results[2].title, "Edition of Example Work")
def test_search_multiple_editions(self): @patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay")
def test_search_multiple_editions(self, _):
"""it should get rid of duplicate editions for the same work""" """it should get rid of duplicate editions for the same work"""
with patch("bookwyrm.preview_images.generate_edition_preview_image_task.delay"):
work = models.Work.objects.create(title="Work Title") work = models.Work.objects.create(title="Work Title")
edition_1 = models.Edition.objects.create( edition_1 = models.Edition.objects.create(
title="Edition 1 Title", parent_work=work title="Edition 1 Title", parent_work=work
@ -90,7 +90,7 @@ class SelfConnector(TestCase):
edition_2 = models.Edition.objects.create( edition_2 = models.Edition.objects.create(
title="Edition 2 Title", title="Edition 2 Title",
parent_work=work, parent_work=work,
edition_rank=20, # that's default babey isbn_13="123456789", # this is now the defualt edition
) )
edition_3 = models.Edition.objects.create(title="Fish", parent_work=work) edition_3 = models.Edition.objects.create(title="Fish", parent_work=work)