Skip to content

Commit

Permalink
Ignore axis now fulfillment
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathangreen committed Dec 12, 2024
1 parent ec00a8e commit d1883b6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/palace/manager/api/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1568,6 +1568,9 @@ def process_one(

info: AxisLoanInfo | HoldInfo | None = None
if checked_out:
checkout_format = self.text_of_optional_subtag(
availability, "axis:checkoutFormat", ns
)
start_date = self._xpath1_date(availability, "axis:checkoutStartDate", ns)
end_date = self._xpath1_date(availability, "axis:checkoutEndDate", ns)
download_url = self.text_of_optional_subtag(
Expand All @@ -1578,6 +1581,14 @@ def process_one(
or ""
)

if not self.internal_format and (
checkout_format == self.api.AXISNOW or checkout_format == "Blio"
):
# If we didn't explicitly ask for a format, ignore any AxisNow or Blio formats, since
# we can't fulfill them. If we add AxisNow and Blio support in the future, we will need
# to drop this line.
return None

fulfillment: Fulfillment | None
if download_url and self.internal_format != self.api.AXISNOW:
# The patron wants a direct link to the book, which we can deliver
Expand Down
8 changes: 7 additions & 1 deletion tests/manager/api/test_axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ def test_fulfill(self, axis360: Axis360Fixture):
pytest.raises(NoActiveLoan, fulfill)

# If an ebook is checked out and we're not asking for it to be
# fulfilled through AxisNow, we get a Axis360AcsFulfillment
# fulfilled through Adobe DRM, we get a Axis360AcsFulfillment
# object with a content link.
data = axis360.sample_data("availability_with_loan_and_hold.xml")
axis360.api.queue_response(200, content=data)
Expand Down Expand Up @@ -551,6 +551,12 @@ def test_patron_activity(self, axis360: Axis360Fixture):
assert isinstance(hold2, HoldInfo)
assert isinstance(loan, LoanInfo)

# If the activity includes something with a Blio format, it is not included in the results.
data = axis360.sample_data("availability_with_axisnow_fulfillment.xml")
axis360.api.queue_response(200, content=data)
results = axis360.api.patron_activity(patron, "pin")
assert len(results) == 0

def test_update_licensepools_for_identifiers(self, axis360: Axis360Fixture):
class Mock(MockAxis360API):
"""Simulates an Axis 360 API that knows about some
Expand Down

0 comments on commit d1883b6

Please sign in to comment.