Merge branch 'main' into book-data-model

This commit is contained in:
Mouse Reeve 2020-12-21 13:16:40 -08:00
commit 15c22fa6c9
4 changed files with 9 additions and 11 deletions

View file

@ -140,7 +140,7 @@ class AbstractConnector(AbstractMinimalConnector):
for author in self.get_authors_from_data(edition_data):
edition.authors.add(author)
if not edition.authors.exists() and work.authors.exists():
edition.authors.add(work.authors.all())
edition.authors.set(work.authors.all())
return edition

View file

@ -174,7 +174,7 @@ def pick_default_edition(options):
if len(options) == 1:
return options[0]
options = [e for e in options if e.get('cover')] or options
options = [e for e in options if e.get('covers')] or options
options = [e for e in options if \
'/languages/eng' in str(e.get('languages'))] or options
formats = ['paperback', 'hardcover', 'mass market paperback']

View file

@ -44,7 +44,7 @@ class Openlibrary(TestCase):
def test_pick_default_edition(self):
edition = pick_default_edition(self.edition_list_data['entries'])
self.assertEqual(edition['key'], '/books/OL9952943M')
self.assertEqual(edition['key'], '/books/OL9788823M')
def test_format_search_result(self):

View file

@ -22,34 +22,32 @@ class SelfConnector(TestCase):
priority=1,
)
self.connector = Connector(DOMAIN)
author = models.Author.objects.create(name='Anonymouse')
self.work = models.Work.objects.create(
title='Example Work',
)
self.work.add(author)
author = models.Author.objects.create(name='Anonymous')
self.edition = models.Edition.objects.create(
title='Edition of Example Work',
published_date=datetime.datetime(1980, 5, 10, tzinfo=timezone.utc),
parent_work=self.work,
)
self.edition.add(author)
edition = models.Edition.objects.create(
self.edition.authors.add(author)
models.Edition.objects.create(
title='Another Edition',
parent_work=self.work,
series='Anonymous'
)
edition.add(author)
edition = models.Edition.objects.create(
models.Edition.objects.create(
title='More Editions',
subtitle='The Anonymous Edition',
parent_work=self.work,
)
edition.add(author)
edition = models.Edition.objects.create(
title='An Edition',
parent_work=self.work
)
edition.add(author)
edition.authors.add(models.Author.objects.create(name='Fish'))
def test_format_search_result(self):