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

SFR-2441: Search format type #509

Merged
merged 4 commits into from
Jan 14, 2025
Merged

SFR-2441: Search format type #509

merged 4 commits into from
Jan 14, 2025

Conversation

ayan1229
Copy link
Contributor

@ayan1229 ayan1229 commented Jan 9, 2025

This test validates if format:readable in request url for search
then either reader or embed value should be True

@ayan1229 ayan1229 changed the title SFR-2441:search_format_type SFR-2441: Search format type Jan 9, 2025
Comment on lines 21 to 24
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}"
Copy link
Contributor

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):
Copy link
Contributor

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")
Copy link
Contributor

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

@kylevillegas93
Copy link
Contributor

@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.

@ayan1229 ayan1229 merged commit 79b4163 into main Jan 14, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants