Merge branch 'main' into book-data-model
This commit is contained in:
commit
15c22fa6c9
|
@ -140,7 +140,7 @@ class AbstractConnector(AbstractMinimalConnector):
|
||||||
for author in self.get_authors_from_data(edition_data):
|
for author in self.get_authors_from_data(edition_data):
|
||||||
edition.authors.add(author)
|
edition.authors.add(author)
|
||||||
if not edition.authors.exists() and work.authors.exists():
|
if not edition.authors.exists() and work.authors.exists():
|
||||||
edition.authors.add(work.authors.all())
|
edition.authors.set(work.authors.all())
|
||||||
|
|
||||||
return edition
|
return edition
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ def pick_default_edition(options):
|
||||||
if len(options) == 1:
|
if len(options) == 1:
|
||||||
return options[0]
|
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 \
|
options = [e for e in options if \
|
||||||
'/languages/eng' in str(e.get('languages'))] or options
|
'/languages/eng' in str(e.get('languages'))] or options
|
||||||
formats = ['paperback', 'hardcover', 'mass market paperback']
|
formats = ['paperback', 'hardcover', 'mass market paperback']
|
||||||
|
|
|
@ -44,7 +44,7 @@ class Openlibrary(TestCase):
|
||||||
|
|
||||||
def test_pick_default_edition(self):
|
def test_pick_default_edition(self):
|
||||||
edition = pick_default_edition(self.edition_list_data['entries'])
|
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):
|
def test_format_search_result(self):
|
||||||
|
|
|
@ -22,34 +22,32 @@ class SelfConnector(TestCase):
|
||||||
priority=1,
|
priority=1,
|
||||||
)
|
)
|
||||||
self.connector = Connector(DOMAIN)
|
self.connector = Connector(DOMAIN)
|
||||||
author = models.Author.objects.create(name='Anonymouse')
|
|
||||||
self.work = models.Work.objects.create(
|
self.work = models.Work.objects.create(
|
||||||
title='Example Work',
|
title='Example Work',
|
||||||
)
|
)
|
||||||
self.work.add(author)
|
author = models.Author.objects.create(name='Anonymous')
|
||||||
self.edition = models.Edition.objects.create(
|
self.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=self.work,
|
parent_work=self.work,
|
||||||
)
|
)
|
||||||
self.edition.add(author)
|
self.edition.authors.add(author)
|
||||||
edition = models.Edition.objects.create(
|
models.Edition.objects.create(
|
||||||
title='Another Edition',
|
title='Another Edition',
|
||||||
parent_work=self.work,
|
parent_work=self.work,
|
||||||
series='Anonymous'
|
series='Anonymous'
|
||||||
)
|
)
|
||||||
edition.add(author)
|
models.Edition.objects.create(
|
||||||
edition = models.Edition.objects.create(
|
|
||||||
title='More Editions',
|
title='More Editions',
|
||||||
subtitle='The Anonymous Edition',
|
subtitle='The Anonymous Edition',
|
||||||
parent_work=self.work,
|
parent_work=self.work,
|
||||||
)
|
)
|
||||||
edition.add(author)
|
|
||||||
edition = models.Edition.objects.create(
|
edition = models.Edition.objects.create(
|
||||||
title='An Edition',
|
title='An Edition',
|
||||||
parent_work=self.work
|
parent_work=self.work
|
||||||
)
|
)
|
||||||
edition.add(author)
|
edition.authors.add(models.Author.objects.create(name='Fish'))
|
||||||
|
|
||||||
|
|
||||||
def test_format_search_result(self):
|
def test_format_search_result(self):
|
||||||
|
|
Loading…
Reference in New Issue