From 309b86686e91adff3dbee5e00125d8d78cbd23bc Mon Sep 17 00:00:00 2001 From: Thomas Date: Fri, 1 Sep 2023 18:52:55 +0800 Subject: [PATCH] Fix tests that relied on specific Pagination responses (#4015) --- .../v1/endpoints/test_messaging_endpoints.py | 1 + .../test_policy_webhook_endpoints.py | 2 + .../test_privacy_preference_endpoints.py | 37 +++++++++++++++++-- .../test_privacy_request_endpoints.py | 4 ++ .../v1/endpoints/test_storage_endpoints.py | 2 + 5 files changed, 42 insertions(+), 4 deletions(-) diff --git a/tests/ops/api/v1/endpoints/test_messaging_endpoints.py b/tests/ops/api/v1/endpoints/test_messaging_endpoints.py index b990ccf70c..bb10a47e3d 100644 --- a/tests/ops/api/v1/endpoints/test_messaging_endpoints.py +++ b/tests/ops/api/v1/endpoints/test_messaging_endpoints.py @@ -812,6 +812,7 @@ def test_get_configs( } ], "page": 1, + "pages": 1, "size": PAGE_SIZE, "total": 1, } diff --git a/tests/ops/api/v1/endpoints/test_policy_webhook_endpoints.py b/tests/ops/api/v1/endpoints/test_policy_webhook_endpoints.py index 77278e909f..1b37a31c21 100644 --- a/tests/ops/api/v1/endpoints/test_policy_webhook_endpoints.py +++ b/tests/ops/api/v1/endpoints/test_policy_webhook_endpoints.py @@ -106,6 +106,7 @@ def test_get_pre_execution_policy_webhooks( ], "total": 2, "page": 1, + "pages": 1, "size": 50, } @@ -174,6 +175,7 @@ def test_get_post_execution_policy_webhooks( ], "total": 2, "page": 1, + "pages": 1, "size": 50, } diff --git a/tests/ops/api/v1/endpoints/test_privacy_preference_endpoints.py b/tests/ops/api/v1/endpoints/test_privacy_preference_endpoints.py index ec86013dff..b744e04fcd 100644 --- a/tests/ops/api/v1/endpoints/test_privacy_preference_endpoints.py +++ b/tests/ops/api/v1/endpoints/test_privacy_preference_endpoints.py @@ -160,7 +160,13 @@ def test_verify_then_set_privacy_preferences( ) assert response.status_code == 200 # Assert no existing privacy preferences exist for this identity - assert response.json() == {"items": [], "total": 0, "page": 1, "size": 50} + assert response.json() == { + "items": [], + "total": 0, + "page": 1, + "pages": 0, + "size": 50, + } response = api_client.patch( f"{V1_URL_PREFIX}{CONSENT_REQUEST_PRIVACY_PREFERENCES_WITH_ID.format(consent_request_id=consent_request.id)}", @@ -244,7 +250,13 @@ def test_verify_then_set_privacy_preferences_but_no_privacy_request_created( ) assert response.status_code == 200 # Assert no existing privacy preferences exist for this identity - assert response.json() == {"items": [], "total": 0, "page": 1, "size": 50} + assert response.json() == { + "items": [], + "total": 0, + "page": 1, + "pages": 0, + "size": 50, + } request_body = { "browser_identity": {"ga_client_id": "test"}, @@ -880,7 +892,13 @@ def test_verify_then_set_privacy_preferences_with_additional_fides_user_device_i ) assert response.status_code == 200 # Assert no existing privacy preferences exist for this identity - assert response.json() == {"items": [], "total": 0, "page": 1, "size": 50} + assert response.json() == { + "items": [], + "total": 0, + "page": 1, + "pages": 0, + "size": 50, + } response = api_client.patch( f"{V1_URL_PREFIX}{CONSENT_REQUEST_PRIVACY_PREFERENCES_WITH_ID.format(consent_request_id=consent_request.id)}", @@ -1055,7 +1073,13 @@ def test_consent_verify_no_privacy_preferences_present( ) assert response.status_code == 200 assert verification_code in mock_verify_identity.call_args_list[0].args - assert response.json() == {"items": [], "total": 0, "page": 1, "size": 50} + assert response.json() == { + "items": [], + "total": 0, + "page": 1, + "pages": 0, + "size": 50, + } @pytest.mark.usefixtures( "subject_identity_verification_required", @@ -1452,6 +1476,7 @@ def test_get_historical_preferences( assert len(response.json()["items"]) == 1 assert response.json()["total"] == 1 assert response.json()["page"] == 1 + assert response.json()["pages"] == 1 assert response.json()["size"] == 50 response_body = response.json()["items"][0] @@ -1513,6 +1538,7 @@ def test_get_historical_preferences_user_geography_unsupported( assert len(response.json()["items"]) == 1 assert response.json()["total"] == 1 assert response.json()["page"] == 1 + assert response.json()["pages"] == 1 assert response.json()["size"] == 50 response_body = response.json()["items"][0] @@ -1538,6 +1564,7 @@ def test_get_historical_preferences_ordering( assert len(response.json()["items"]) == 3 assert response.json()["total"] == 3 assert response.json()["page"] == 1 + assert response.json()["pages"] == 1 assert response.json()["size"] == 50 response_body = response.json()["items"] @@ -1667,6 +1694,7 @@ def test_get_current_preferences( assert len(response.json()["items"]) == 1 assert response.json()["total"] == 1 assert response.json()["page"] == 1 + assert response.json()["pages"] == 1 assert response.json()["size"] == 50 response_body = response.json()["items"][0] @@ -1698,6 +1726,7 @@ def test_get_current_preference_ordering( assert len(response.json()["items"]) == 3 assert response.json()["total"] == 3 assert response.json()["page"] == 1 + assert response.json()["pages"] == 1 assert response.json()["size"] == 50 response_body = response.json()["items"] diff --git a/tests/ops/api/v1/endpoints/test_privacy_request_endpoints.py b/tests/ops/api/v1/endpoints/test_privacy_request_endpoints.py index 480df0274c..cd05e14ce5 100644 --- a/tests/ops/api/v1/endpoints/test_privacy_request_endpoints.py +++ b/tests/ops/api/v1/endpoints/test_privacy_request_endpoints.py @@ -713,6 +713,7 @@ def test_get_privacy_requests_by_id( ], "total": 1, "page": 1, + "pages": 1, "size": page_size, } @@ -773,6 +774,7 @@ def test_get_privacy_requests_by_partial_id( ], "total": 1, "page": 1, + "pages": 1, "size": page_size, } @@ -1238,6 +1240,7 @@ def test_verbose_privacy_requests( ], "total": 1, "page": 1, + "pages": 1, "size": page_size, } assert resp == expected_resp @@ -1690,6 +1693,7 @@ def test_get_execution_logs( ], "total": 3, "page": 1, + "pages": 1, "size": page_size, } diff --git a/tests/ops/api/v1/endpoints/test_storage_endpoints.py b/tests/ops/api/v1/endpoints/test_storage_endpoints.py index 2af9932c40..d9f0481860 100644 --- a/tests/ops/api/v1/endpoints/test_storage_endpoints.py +++ b/tests/ops/api/v1/endpoints/test_storage_endpoints.py @@ -504,6 +504,7 @@ def test_get_configs( } ], "page": 1, + "pages": 1, "size": PAGE_SIZE, "total": 1, } @@ -679,6 +680,7 @@ def test_get_default_configs( } ], "page": 1, + "pages": 1, "size": PAGE_SIZE, "total": 1, }