From 0ab86bb4e196b1b2d77c8fa894f36548d9069898 Mon Sep 17 00:00:00 2001 From: Debbie San Date: Sun, 29 Sep 2024 21:23:11 -0600 Subject: [PATCH] adding independent publisher check --- openlibrary/catalog/utils/__init__.py | 3 ++- openlibrary/tests/catalog/test_utils.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/openlibrary/catalog/utils/__init__.py b/openlibrary/catalog/utils/__init__.py index bec37c41244..77f7c5c6757 100644 --- a/openlibrary/catalog/utils/__init__.py +++ b/openlibrary/catalog/utils/__init__.py @@ -322,8 +322,9 @@ def is_independently_published(publishers: list[str]) -> bool: """ Return True if the book is independently published. """ + independent_publisher_names = ['independently published', 'independent publisher'] return any( - publisher.casefold() == "independently published" for publisher in publishers + publisher.casefold() in independent_publisher_names for publisher in publishers ) diff --git a/openlibrary/tests/catalog/test_utils.py b/openlibrary/tests/catalog/test_utils.py index f5107d08f5e..d09ef1eba23 100644 --- a/openlibrary/tests/catalog/test_utils.py +++ b/openlibrary/tests/catalog/test_utils.py @@ -289,7 +289,9 @@ def test_publication_too_old_and_not_exempt(name, rec, expected) -> None: 'publishers, expected', [ (['INDEPENDENTLY PUBLISHED'], True), + (['Independent publisher'], True), (['Another Publisher', 'independently published'], True), + (['Another Publisher', 'independent publisher'], True), (['Another Publisher'], False), ], )