Skip to content

Commit

Permalink
tests: loan request: fix test for minimum days before request
Browse files Browse the repository at this point in the history
  • Loading branch information
sakshamarora1 committed Mar 13, 2024
1 parent 5c00f56 commit 139d90b
Showing 1 changed file with 6 additions and 15 deletions.
21 changes: 6 additions & 15 deletions tests/api/circulation/test_loan_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,8 @@ def test_request_loan_minimum_days(app, client, json_headers, users, testdata):
assert res.status_code == 400
assert res.get_json()["message"] == "Validation error."

params["document_pid"] = "docid-7"
end_date = (now + timedelta(days=4)).date().isoformat() # PASS
params["request_expire_date"] = end_date
res = client.post(url, headers=json_headers, data=json.dumps(params))
assert res.status_code == 202
loan = res.get_json()["metadata"]
assert loan["state"] == "PENDING"
assert loan["document_pid"] == params["document_pid"]
assert loan["transaction_date"]

params["document_pid"] = "docid-8"
end_date = (now + timedelta(days=8)).date().isoformat() # PASS
end_date = (now + timedelta(days=7)).date().isoformat() # PASS
params["request_expire_date"] = end_date
res = client.post(url, headers=json_headers, data=json.dumps(params))
assert res.status_code == 202
Expand All @@ -299,17 +289,18 @@ def test_request_loan_minimum_days(app, client, json_headers, users, testdata):

app.config["ILS_CIRCULATION_LOAN_REQUEST_OFFSET"] = 2

params["document_pid"] = "docid-11"
start_date_friday = now + timedelta(days=(4 - now.weekday() + 7) % 7)
params["request_start_date"] = start_date_friday
params["request_start_date"] = start_date_friday.date().isoformat()

end_date_monday = (now + timedelta(days=3)).date().isoformat() # FAIL
params["document_pid"] = "docid-11"
end_date_monday = (start_date_friday + timedelta(days=3)).date().isoformat() # FAIL
params["request_expire_date"] = end_date_monday
res = client.post(url, headers=json_headers, data=json.dumps(params))
assert res.status_code == 400

Check failure on line 299 in tests/api/circulation/test_loan_request.py

View workflow job for this annotation

GitHub Actions / Tests (circulation, 3.9, pypi, postgresql13, opensearch2)

test_request_loan_minimum_days assert 202 == 400 + where 202 = <WrapperTestResponse streamed [202 ACCEPTED]>.status_code

Check failure on line 299 in tests/api/circulation/test_loan_request.py

View workflow job for this annotation

GitHub Actions / Tests (circulation, 3.9, pypi, postgresql14, opensearch2)

test_request_loan_minimum_days assert 202 == 400 + where 202 = <WrapperTestResponse streamed [202 ACCEPTED]>.status_code
assert res.get_json()["message"] == "Validation error."

end_date_tuesday = (now + timedelta(days=4)).date().isoformat() # PASS
params["document_pid"] = "docid-12"
end_date_tuesday = (start_date_friday + timedelta(days=4)).date().isoformat() # PASS
params["request_expire_date"] = end_date_tuesday
res = client.post(url, headers=json_headers, data=json.dumps(params))
assert res.status_code == 202
Expand Down

0 comments on commit 139d90b

Please sign in to comment.