-
Notifications
You must be signed in to change notification settings - Fork 1
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
SFR-2441: Search format type #509
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import pytest | ||
import requests | ||
from urllib.parse import quote | ||
from .constants import API_URL | ||
|
||
@pytest.mark.parametrize("endpoint", [ | ||
("/search?query=keyword:NASA&filter=format:readable") | ||
]) | ||
def test_readable_format_flags(endpoint): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think what we are testing here is that the search format filter is working as expected. I recommend changing the test name to reflect that. |
||
url = API_URL + quote(endpoint) | ||
response = requests.get(url) | ||
|
||
response_json = response.json() | ||
assert response_json is not None, "Response JSON is empty" | ||
|
||
works = response_json.get('data', {}).get('works', []) | ||
|
||
for work in works: | ||
for edition in work.get('editions', []): | ||
for item in edition.get('items', []): | ||
if any(link.get('mediaType') == "text/html" for link in item.get('links', [])): | ||
flags = item.get('links', [])[0].get('flags', {}) | ||
assert flags.get('reader', False) or flags.get('embed', False), \ | ||
f"Flags validation failed: {flags}" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's pull the html links out here and check to make sure that the reader flag is false and the embed is true for each one. The logic you have here checks if any link has a media type of text/html but then grabs the first link's flags. However, the link at that index may not have a mediaType of "text/html". You could potentially go further here and check other media type and ensure that the reader flag is True (I think). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also try to test downloadable format