From b82b6ea664bcd4dd373d67698cb80491960c57d2 Mon Sep 17 00:00:00 2001 From: Dawn Pattison Date: Sun, 23 Apr 2023 18:12:50 -0500 Subject: [PATCH] Improve test coverage on the method that fetches fides user device id provided identity. --- .../test_consent_request_endpoints.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/ops/api/v1/endpoints/test_consent_request_endpoints.py b/tests/ops/api/v1/endpoints/test_consent_request_endpoints.py index bc06df0895..6a29d040f7 100644 --- a/tests/ops/api/v1/endpoints/test_consent_request_endpoints.py +++ b/tests/ops/api/v1/endpoints/test_consent_request_endpoints.py @@ -8,6 +8,9 @@ import pytest from requests import Session +from fides.api.ops.api.v1.endpoints.consent_request_endpoints import ( + _get_fides_user_device_id_provided_identity, +) from fides.api.ops.api.v1.scope_registry import CONNECTION_READ, CONSENT_READ from fides.api.ops.api.v1.urn_registry import ( CONSENT_REQUEST, @@ -1165,3 +1168,23 @@ def test_get_consent_preferences( }, ] assert response.json()["consent"] == expected_consent_data + + +class TestGetFidesUserProvidedIdentity: + def test_no_identifier_supplied(self, db): + provided_identity = _get_fides_user_device_id_provided_identity(db, None) + assert provided_identity is None + + def test_no_provided_identifier_exists(self, db): + provided_identity = _get_fides_user_device_id_provided_identity( + db, "fides_user_device_id" + ) + assert provided_identity is None + + def test_get_fides_user_device_id_provided_identity( + self, db, fides_user_provided_identity + ): + provided_identity = _get_fides_user_device_id_provided_identity( + db, "FGHIJ_TEST_FIDES" + ) + assert provided_identity == fides_user_provided_identity