-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
4 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,20 @@ | ||
import requests | ||
import pytest | ||
|
||
|
||
BASE_URL = "https://drb-api-qa.nypl.org" | ||
|
||
def test_get_collection(): | ||
|
||
url = BASE_URL + "/collection/3650664c-c8be-4d07-8d64-2d7003b02048" | ||
expected_status_code = 200 | ||
response = requests.get(url) | ||
assert expected_status_code is not None | ||
assert response.status_code == expected_status_code, ( | ||
f"API call failed.\n" | ||
f"Expected status code: {expected_status_code}\n" | ||
f"Actual status code: {response.status_code}\n" | ||
f"URL: {url}\n" | ||
f"Response text: {response.text[:100]}..." | ||
) | ||
|
||
data = response.json() | ||
|
||
expected_title = "Works by Ayan" | ||
actual_title = data.get("metadata", {}).get("title", "") | ||
|
||
assert actual_title == expected_title, f"Expected title '{expected_title}', but got '{actual_title}'" | ||
|
||
first_publication_title = data.get('publications', [])[0].get('metadata', {}).get('title') | ||
assert first_publication_title == "New Mexico magazine ", f"Expected first title 'New Mexico magazine ', but got {first_publication_title}" | ||
|
||
second_publication_title = data.get('publications', [])[1].get('metadata', {}).get('title') | ||
assert second_publication_title == "New Mexico magazine index. ", f"Expected second title 'New Mexico magazine index. ', but got {second_publication_title}" | ||
|
||
response_json = response.json() | ||
assert response_json is not None |