Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix API integration test for the related endpoint #3331

Merged
merged 1 commit into from
Nov 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions api/test/media_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,21 +152,23 @@ def uuid_validation(media_type, identifier):
def related(fixture):
item = fixture["results"][0]

def get_terms_set(item):
return set([t["name"] for t in item["tags"]] + item["title"].split(" "))
response = requests.get(item["related_url"]).json()
results = response["results"]

terms_set = get_terms_set(item)
related_url = item["related_url"]
raw_response = requests.get(related_url)
response = raw_response.json()

assert raw_response.status_code == 200
assert response["result_count"] == len(response["results"]) == 10
assert response["result_count"] == len(results) == 10
assert response["page_count"] == 1

# Make sure each result has at least one word in common with the original item
for result in response["results"]:
assert len(terms_set.intersection(get_terms_set(result))) > 0
def get_terms_set(res):
return set([t["name"] for t in res["tags"]] + res["title"].split(" "))

terms_set = get_terms_set(item)
# Make sure each result has at least one word in common with the original item,
# or is by the same creator.
for result in results:
assert (
len(terms_set.intersection(get_terms_set(result))) > 0
or result["creator"] == item["creator"]
)


def sensitive_search_and_detail(media_type):
Expand Down