diff --git a/bookwyrm/connectors/openlibrary.py b/bookwyrm/connectors/openlibrary.py index fb9a4e47..c83a65d6 100644 --- a/bookwyrm/connectors/openlibrary.py +++ b/bookwyrm/connectors/openlibrary.py @@ -161,21 +161,17 @@ def ignore_edition(edition_data): """ don't load a million editions that have no metadata """ # an isbn, we love to see it if edition_data.get("isbn_13") or edition_data.get("isbn_10"): - print(edition_data.get("isbn_10")) return False # grudgingly, oclc can stay if edition_data.get("oclc_numbers"): - print(edition_data.get("oclc_numbers")) return False # if it has a cover it can stay if edition_data.get("covers"): - print(edition_data.get("covers")) return False # keep non-english editions if edition_data.get("languages") and "languages/eng" not in str( edition_data.get("languages") ): - print(edition_data.get("languages")) return False return True diff --git a/bookwyrm/tests/connectors/test_openlibrary_connector.py b/bookwyrm/tests/connectors/test_openlibrary_connector.py index bb018830..3cff4fb0 100644 --- a/bookwyrm/tests/connectors/test_openlibrary_connector.py +++ b/bookwyrm/tests/connectors/test_openlibrary_connector.py @@ -8,6 +8,7 @@ import responses from bookwyrm import models from bookwyrm.connectors.openlibrary import Connector +from bookwyrm.connectors.openlibrary import ignore_edition from bookwyrm.connectors.openlibrary import get_languages, get_description from bookwyrm.connectors.openlibrary import pick_default_edition, get_openlibrary_key from bookwyrm.connectors.abstract_connector import SearchResult @@ -237,3 +238,12 @@ class Openlibrary(TestCase): self.assertEqual(result.pages, 491) self.assertEqual(result.subjects[0], "Fantasy.") self.assertEqual(result.physical_format, "Hardcover") + + def test_ignore_edition(self): + """ skip editions with poor metadata """ + self.assertFalse(ignore_edition({"isbn_13": "hi"})) + self.assertFalse(ignore_edition({"oclc_numbers": "hi"})) + self.assertFalse(ignore_edition({"covers": "hi"})) + self.assertFalse(ignore_edition({"languages": "languages/fr"})) + self.assertTrue(ignore_edition({"languages": "languages/eng"})) + self.assertTrue(ignore_edition({"format": "paperback"}))