Skip to content

Commit

Permalink
PP-1219: Fixes overdrive monitor failures. (#1819)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbernstein authored May 2, 2024
1 parent 0b4518a commit 80384b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
12 changes: 3 additions & 9 deletions api/overdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class OverdriveAPI(
METADATA_ENDPOINT = (
"%(host)s/v1/collections/%(collection_token)s/products/%(item_id)s/metadata"
)
EVENTS_ENDPOINT = "%(host)s/v1/collections/%(collection_token)s/products?lastUpdateTime=%(lastupdatetime)s&sort=%(sort)s&limit=%(limit)s"
EVENTS_ENDPOINT = "%(host)s/v1/collections/%(collection_token)s/products?lastUpdateTime=%(lastupdatetime)s&limit=%(limit)s"
AVAILABILITY_ENDPOINT = "%(host)s/v2/collections/%(collection_token)s/products/%(product_id)s/availability"

PATRON_INFORMATION_ENDPOINT = "%(patron_host)s/v1/patrons/me"
Expand Down Expand Up @@ -2036,14 +2036,8 @@ class NewTitlesOverdriveCollectionMonitor(OverdriveCirculationMonitor):
DEFAULT_START_TIME = OverdriveCirculationMonitor.NEVER
MAX_CONSECUTIVE_OUT_OF_SCOPE_DATES = 1000

def __init__(
self,
_db,
collection,
api_class=OverdriveAPI,
analytics: Analytics = Provide[Services.analytics.analytics],
):
super().__init__(_db, collection, api_class, analytics)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._consecutive_items_out_of_scope = 0

def recently_changed_ids(self, start, cutoff):
Expand Down
10 changes: 10 additions & 0 deletions tests/api/test_overdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -2233,6 +2233,16 @@ def test_no_drm_fulfillment(self, overdrive_api_fixture: OverdriveAPIFixture):
assert fulfill.content_link_redirect is True
assert fulfill.content_link == "https://example.org/epub-redirect"

def test_no_recently_changed_books(
self, overdrive_api_fixture: OverdriveAPIFixture
):
with patch.object(
overdrive_api_fixture.api, "_get_book_list_page"
) as get_book_list:
get_book_list.return_value = ([], None)
result = overdrive_api_fixture.api.recently_changed_ids(utc_now(), None)
assert [i for i in result] == []


class TestOverdriveAPICredentials:
def test_patron_correct_credentials_for_multiple_overdrive_collections(
Expand Down

0 comments on commit 80384b1

Please sign in to comment.