From b9a75cde222a646ca6a86a318d6e41d4bd0c7c62 Mon Sep 17 00:00:00 2001 From: Saksham Date: Wed, 14 Aug 2024 16:13:57 +0200 Subject: [PATCH] tests: Update tests to include locale in Link --- tests/resources/test_resource_faceting.py | 6 ++--- tests/resources/test_resource_pagination.py | 26 ++++++++++----------- tests/resources/test_resource_sorting.py | 10 ++++---- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/tests/resources/test_resource_faceting.py b/tests/resources/test_resource_faceting.py index 787feb8d..2ac8f967 100644 --- a/tests/resources/test_resource_faceting.py +++ b/tests/resources/test_resource_faceting.py @@ -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" ), } @@ -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" ), } diff --git a/tests/resources/test_resource_pagination.py b/tests/resources/test_resource_pagination.py index ca16db23..c91e2baa 100644 --- a/tests/resources/test_resource_pagination.py +++ b/tests/resources/test_resource_pagination.py @@ -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 @@ -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] @@ -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] @@ -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] @@ -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] @@ -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" ), } diff --git a/tests/resources/test_resource_sorting.py b/tests/resources/test_resource_sorting.py index a0ac66eb..05112fc8 100644 --- a/tests/resources/test_resource_sorting.py +++ b/tests/resources/test_resource_sorting.py @@ -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(): @@ -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] @@ -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" ), }