-
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
Conversation
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 comment
The 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).
@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 comment
The 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.
from .constants import API_URL | ||
|
||
@pytest.mark.parametrize("endpoint", [ | ||
("/search?query=keyword:NASA&filter=format:readable") |
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
@ayan1229 Test overall looked good. I do recommend focusing on keeping things simple! No need to dive into the data too much. Just want to use the bear minimum to confirm that the format filter is working. I went ahead and made some changes to simplify things. I recommend checking out list comprehension! Also, the quote wasn't working correctly so the test wasn't actually calling the search endpoint. I've fixed that but I recommend going through the rest of the tests to confirm that they are working as expected. |
This test validates if format:readable in request url for search
then either reader or embed value should be True