Adds isbn search test to connector manager

This commit is contained in:
Mouse Reeve
2021-03-13 10:01:17 -08:00
parent 6b22de2075
commit 414dd6bd20
2 changed files with 12 additions and 3 deletions

View File

@ -15,7 +15,7 @@ class ConnectorManager(TestCase):
self.work = models.Work.objects.create(title="Example Work")
self.edition = models.Edition.objects.create(
title="Example Edition", parent_work=self.work
title="Example Edition", parent_work=self.work, isbn_10="0000000000"
)
self.work.default_edition = self.edition
self.work.save()
@ -28,6 +28,7 @@ class ConnectorManager(TestCase):
base_url="http://test.com/",
books_url="http://test.com/",
covers_url="http://test.com/",
isbn_search_url="http://test.com/isbn/",
)
def test_get_or_create_connector(self):
@ -58,6 +59,14 @@ class ConnectorManager(TestCase):
self.assertEqual(len(results[0]["results"]), 1)
self.assertEqual(results[0]["results"][0].title, "Example Edition")
def test_search_isbn(self):
""" special handling if a query resembles an isbn """
results = connector_manager.search("0000000000")
self.assertEqual(len(results), 1)
self.assertIsInstance(results[0]["connector"], SelfConnector)
self.assertEqual(len(results[0]["results"]), 1)
self.assertEqual(results[0]["results"][0].title, "Example Edition")
def test_local_search(self):
""" search only the local database """
results = connector_manager.local_search("Example")