diff --git a/bookwyrm/connectors/connector_manager.py b/bookwyrm/connectors/connector_manager.py index 0488421e9..fc7849249 100644 --- a/bookwyrm/connectors/connector_manager.py +++ b/bookwyrm/connectors/connector_manager.py @@ -46,7 +46,9 @@ async def get_results(session, url, min_confidence, query, connector): return { "connector": connector, - "results": connector.process_search_response(query, raw_data, min_confidence), + "results": connector.process_search_response( + query, raw_data, min_confidence + ), } except asyncio.TimeoutError: logger.info("Connection timed out for url: %s", url) diff --git a/bookwyrm/tests/connectors/test_bookwyrm_connector.py b/bookwyrm/tests/connectors/test_bookwyrm_connector.py index b9642a50e..1e369ca01 100644 --- a/bookwyrm/tests/connectors/test_bookwyrm_connector.py +++ b/bookwyrm/tests/connectors/test_bookwyrm_connector.py @@ -34,7 +34,7 @@ class BookWyrmConnector(TestCase): """create a SearchResult object from search response json""" datafile = pathlib.Path(__file__).parent.joinpath("../data/bw_search.json") search_data = json.loads(datafile.read_bytes()) - result = list(self.connector.parse_search_data(search_data))[0] + result = list(self.connector.parse_search_data(search_data, 0))[0] self.assertIsInstance(result, SearchResult) self.assertEqual(result.title, "Jonathan Strange and Mr Norrell") self.assertEqual(result.key, "https://example.com/book/122") diff --git a/bookwyrm/tests/connectors/test_inventaire_connector.py b/bookwyrm/tests/connectors/test_inventaire_connector.py index 7b526f224..3bba9ece3 100644 --- a/bookwyrm/tests/connectors/test_inventaire_connector.py +++ b/bookwyrm/tests/connectors/test_inventaire_connector.py @@ -73,7 +73,7 @@ class Inventaire(TestCase): ) search_results = json.loads(search_file.read_bytes()) - formatted = list(self.connector.parse_search_data(search_results))[0] + formatted = list(self.connector.parse_search_data(search_results, 0))[0] self.assertEqual(formatted.title, "The Stories of Vladimir Nabokov") self.assertEqual( diff --git a/bookwyrm/tests/connectors/test_openlibrary_connector.py b/bookwyrm/tests/connectors/test_openlibrary_connector.py index c05eb1a94..69e4f847c 100644 --- a/bookwyrm/tests/connectors/test_openlibrary_connector.py +++ b/bookwyrm/tests/connectors/test_openlibrary_connector.py @@ -122,21 +122,11 @@ class Openlibrary(TestCase): self.assertEqual(result, "https://covers.openlibrary.org/b/id/image-L.jpg") def test_parse_search_result(self): - """extract the results from the search json response""" - datafile = pathlib.Path(__file__).parent.joinpath("../data/ol_search.json") - search_data = json.loads(datafile.read_bytes()) - result = self.connector.parse_search_data(search_data) - self.assertIsInstance(result, list) - self.assertEqual(len(result), 2) - - def test_format_search_result(self): """translate json from openlibrary into SearchResult""" datafile = pathlib.Path(__file__).parent.joinpath("../data/ol_search.json") search_data = json.loads(datafile.read_bytes()) - results = self.connector.parse_search_data(search_data) - self.assertIsInstance(results, list) + result = list(self.connector.parse_search_data(search_data, 0))[0] - result = self.connector.format_search_result(results[0]) self.assertIsInstance(result, SearchResult) self.assertEqual(result.title, "This Is How You Lose the Time War") self.assertEqual(result.key, "https://openlibrary.org/works/OL20639540W") @@ -148,18 +138,10 @@ class Openlibrary(TestCase): """extract the results from the search json response""" datafile = pathlib.Path(__file__).parent.joinpath("../data/ol_isbn_search.json") search_data = json.loads(datafile.read_bytes()) - result = self.connector.parse_isbn_search_data(search_data) - self.assertIsInstance(result, list) + result = list(self.connector.parse_isbn_search_data(search_data)) self.assertEqual(len(result), 1) - def test_format_isbn_search_result(self): - """translate json from openlibrary into SearchResult""" - datafile = pathlib.Path(__file__).parent.joinpath("../data/ol_isbn_search.json") - search_data = json.loads(datafile.read_bytes()) - results = self.connector.parse_isbn_search_data(search_data) - self.assertIsInstance(results, list) - - result = self.connector.format_isbn_search_result(results[0]) + result = result[0] self.assertIsInstance(result, SearchResult) self.assertEqual(result.title, "Les ombres errantes") self.assertEqual(result.key, "https://openlibrary.org/books/OL16262504M")