Skip to content

Commit

Permalink
tests: Update tests to include locale in Link
Browse files Browse the repository at this point in the history
  • Loading branch information
sakshamarora1 committed Aug 14, 2024
1 parent d7fae4c commit b9a75cd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions tests/resources/test_resource_faceting.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def test_links_keep_facets(client, headers, three_indexed_records):
response_links = response.json["links"]
expected_links = {
"self": (
"https://127.0.0.1:5000/api/mocks?"
"https://127.0.0.1:5000/api/mocks?locale=en&"
"page=1&size=25&sort=newest&type=A%2A%2AB"
),
}
Expand All @@ -293,11 +293,11 @@ def test_links_keep_repeated_facets(client, headers, three_indexed_records):
response_links = response.json["links"]
expected_links = {
"self": (
"https://127.0.0.1:5000/api/mocks?page=1&size=1&sort=newest"
"https://127.0.0.1:5000/api/mocks?locale=en&page=1&size=1&sort=newest"
"&type=B&type=A"
),
"next": (
"https://127.0.0.1:5000/api/mocks?page=2&size=1&sort=newest"
"https://127.0.0.1:5000/api/mocks?locale=en&page=2&size=1&sort=newest"
"&type=B&type=A"
),
}
Expand Down
26 changes: 13 additions & 13 deletions tests/resources/test_resource_pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ def test_middle_search_result_has_next_and_prev_links(

response_links = response.json["links"]
expected_links = {
"self": "https://127.0.0.1:5000/api/mocks?page=2&size=1&sort=newest",
"prev": "https://127.0.0.1:5000/api/mocks?page=1&size=1&sort=newest",
"next": "https://127.0.0.1:5000/api/mocks?page=3&size=1&sort=newest",
"self": "https://127.0.0.1:5000/api/mocks?locale=en&page=2&size=1&sort=newest",
"prev": "https://127.0.0.1:5000/api/mocks?locale=en&page=1&size=1&sort=newest",
"next": "https://127.0.0.1:5000/api/mocks?locale=en&page=3&size=1&sort=newest",
}

# NOTE: This is done so that we only test for pagination links
Expand All @@ -129,8 +129,8 @@ def test_first_search_result_has_next_and_no_prev_link(

response_links = response.json["links"]
expected_links = {
"self": "https://127.0.0.1:5000/api/mocks?page=1&size=1&sort=newest",
"next": "https://127.0.0.1:5000/api/mocks?page=2&size=1&sort=newest",
"self": "https://127.0.0.1:5000/api/mocks?locale=en&page=1&size=1&sort=newest",
"next": "https://127.0.0.1:5000/api/mocks?locale=en&page=2&size=1&sort=newest",
}
for key, url in expected_links.items():
assert url == response_links[key]
Expand All @@ -145,8 +145,8 @@ def test_last_search_result_has_prev_link_and_no_next_link(

response_links = response.json["links"]
expected_links = {
"self": "https://127.0.0.1:5000/api/mocks?page=3&size=1&sort=newest",
"prev": "https://127.0.0.1:5000/api/mocks?page=2&size=1&sort=newest",
"self": "https://127.0.0.1:5000/api/mocks?locale=en&page=3&size=1&sort=newest",
"prev": "https://127.0.0.1:5000/api/mocks?locale=en&page=2&size=1&sort=newest",
}
for key, url in expected_links.items():
assert url == response_links[key]
Expand All @@ -161,8 +161,8 @@ def test_beyond_last_search_has_prev_link_and_no_next_link(

response_links = response.json["links"]
expected_links = {
"self": "https://127.0.0.1:5000/api/mocks?page=4&size=1&sort=newest",
"prev": "https://127.0.0.1:5000/api/mocks?page=3&size=1&sort=newest",
"self": "https://127.0.0.1:5000/api/mocks?locale=en&page=4&size=1&sort=newest",
"prev": "https://127.0.0.1:5000/api/mocks?locale=en&page=3&size=1&sort=newest",
}
for key, url in expected_links.items():
assert url == response_links[key]
Expand All @@ -177,7 +177,7 @@ def test_beyond_beyond_last_search_has_no_prev_or_next_link(

response_links = response.json["links"]
expected_links = {
"self": "https://127.0.0.1:5000/api/mocks?page=5&size=1&sort=newest",
"self": "https://127.0.0.1:5000/api/mocks?locale=en&page=5&size=1&sort=newest",
}
for key, url in expected_links.items():
assert url == response_links[key]
Expand All @@ -192,15 +192,15 @@ def test_searchstring_is_preserved(client, headers, three_indexed_records):
response_links = response.json["links"]
expected_links = {
"self": (
"https://127.0.0.1:5000/api/mocks?page=2&q=test%20foo&size=1"
"https://127.0.0.1:5000/api/mocks?locale=en&page=2&q=test%20foo&size=1"
"&sort=bestmatch"
),
"prev": (
"https://127.0.0.1:5000/api/mocks?page=1&q=test%20foo&size=1"
"https://127.0.0.1:5000/api/mocks?locale=en&page=1&q=test%20foo&size=1"
"&sort=bestmatch"
),
"next": (
"https://127.0.0.1:5000/api/mocks?page=3&q=test%20foo&size=1"
"https://127.0.0.1:5000/api/mocks?locale=en&page=3&q=test%20foo&size=1"
"&sort=bestmatch"
),
}
Expand Down
10 changes: 5 additions & 5 deletions tests/resources/test_resource_sorting.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ def test_sort_in_links_no_matter_if_sort_in_url(client, headers, three_indexed_r

response_links = response.json["links"]
expected_links = {
"self": ("https://127.0.0.1:5000/api/mocks?page=1&size=1&sort=newest"),
"next": ("https://127.0.0.1:5000/api/mocks?page=2&size=1&sort=newest"),
"self": ("https://127.0.0.1:5000/api/mocks?locale=en&page=1&size=1&sort=newest"),
"next": ("https://127.0.0.1:5000/api/mocks?locale=en&page=2&size=1&sort=newest"),
}
# NOTE: This is done so that we only test for pagination links
for key, url in expected_links.items():
Expand All @@ -113,8 +113,8 @@ def test_sort_in_links_no_matter_if_sort_in_url(client, headers, three_indexed_r

response_links = response.json["links"]
expected_links = {
"self": ("https://127.0.0.1:5000/api/mocks?page=1&size=1&sort=newest"),
"next": ("https://127.0.0.1:5000/api/mocks?page=2&size=1&sort=newest"),
"self": ("https://127.0.0.1:5000/api/mocks?locale=en&page=1&size=1&sort=newest"),
"next": ("https://127.0.0.1:5000/api/mocks?locale=en&page=2&size=1&sort=newest"),
}
for key, url in expected_links.items():
assert url == response_links[key]
Expand All @@ -126,7 +126,7 @@ def test_searchstring_is_preserved(client, headers, three_indexed_records):
response_links = response.json["links"]
expected_links = {
"self": (
"https://127.0.0.1:5000/api/mocks?page=1&q=the%20quick&size=25"
"https://127.0.0.1:5000/api/mocks?locale=en&page=1&q=the%20quick&size=25"
"&sort=newest"
),
}
Expand Down

0 comments on commit b9a75cd

Please sign in to comment.