Skip to content

Commit

Permalink
remove data assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
ayan1229 committed Sep 17, 2024
1 parent 9e58c3d commit e01be91
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions tests/rest_api/test_get_collection.py
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

0 comments on commit e01be91

Please sign in to comment.