Skip to content

Commit

Permalink
EKIR-213 Add test for new exception
Browse files Browse the repository at this point in the history
  • Loading branch information
natlibfi-kaisa committed Sep 18, 2024
1 parent 8b69b4e commit de75560
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/api/controller/test_loan.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from api.circulation_exceptions import (
AlreadyOnHold,
NoAvailableCopies,
NoAvailableCopiesWhenReserved,
NoLicenses,
NotFoundOnRemote,
PatronHoldLimitReached,
Expand Down Expand Up @@ -1091,6 +1092,26 @@ def test_hold_fails_when_patron_is_at_hold_limit(self, loan_fixture: LoanFixture
assert isinstance(response, ProblemDetail)
assert HOLD_LIMIT_REACHED.uri == response.uri

def test_loan_fails_when_patron_is_at_hold_limit_and_hold_position_zero(
self, loan_fixture: LoanFixture
):
edition, pool = loan_fixture.db.edition(with_license_pool=True)
pool.open_access = False
with loan_fixture.request_context_with_library(
"/", headers=dict(Authorization=loan_fixture.valid_auth)
):
patron = loan_fixture.manager.loans.authenticated_patron_from_request()
loan_fixture.manager.d_circulation.queue_checkout(pool, NoAvailableCopies())
loan_fixture.manager.d_circulation.queue_hold(
pool, NoAvailableCopiesWhenReserved()
)
response = loan_fixture.manager.loans.borrow(
pool.identifier.type, pool.identifier.identifier
)
assert isinstance(response, ProblemDetail)
assert NO_COPIES_WHEN_RESERVED.uri == response.uri
assert 403 == response.status_code

def test_borrow_fails_with_outstanding_fines(
self, loan_fixture: LoanFixture, library_fixture: LibraryFixture
):
Expand Down

0 comments on commit de75560

Please sign in to comment.