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

Fix broken fuzzy search tests #5301

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/fixtures/application_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1567,7 +1567,7 @@ def privacy_request(

@pytest.fixture(scope="function")
def bulk_privacy_requests_with_various_identities(db: Session, policy: Policy) -> None:
num_records = 2000000 # 2 million
num_records = 100 # for now only use 100 records as using magnitudes more will cause pytest to timeout
for i in range(num_records):
random_email = generate_random_email()
random_phone_number = generate_random_phone_number()
Expand Down
29 changes: 11 additions & 18 deletions tests/ops/api/v1/endpoints/test_privacy_request_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ def test_fuzzy_search_bulk_privacy_requests_cache_exists(
auth_header = generate_auth_header(scopes=[PRIVACY_REQUEST_READ])

# Test two matches on email
FUZZY_SEARCH_STR_1 = "te"
FUZZY_SEARCH_STR_1 = "test-"
response = api_client.get(
url + f"?fuzzy_search_str={FUZZY_SEARCH_STR_1}",
headers=auth_header,
Expand All @@ -1303,9 +1303,9 @@ def test_fuzzy_search_bulk_privacy_requests_cache_exists(
]

# Test one on email prefix
FUZZY_SEARCH_STR_1 = "test-happy@exam"
FUZZY_SEARCH_STR_2 = "test-happy@exam"
response = api_client.get(
url + f"?fuzzy_search_str={FUZZY_SEARCH_STR_1}",
url + f"?fuzzy_search_str={FUZZY_SEARCH_STR_2}",
headers=auth_header,
)
assert 200 == response.status_code
Expand All @@ -1322,9 +1322,9 @@ def test_fuzzy_search_bulk_privacy_requests_cache_exists(
]

# Test one match on email full
FUZZY_SEARCH_STR_1 = "test-happy@example.com"
FUZZY_SEARCH_STR_3 = "test-happy@example.com"
response = api_client.get(
url + f"?fuzzy_search_str={FUZZY_SEARCH_STR_1}",
url + f"?fuzzy_search_str={FUZZY_SEARCH_STR_3}",
headers=auth_header,
)
assert 200 == response.status_code
Expand All @@ -1341,9 +1341,9 @@ def test_fuzzy_search_bulk_privacy_requests_cache_exists(
]

# Test one match on phone number
FUZZY_SEARCH_STR_1 = "+11232"
FUZZY_SEARCH_STR_4 = "%2B11232"
response = api_client.get(
url + f"?fuzzy_search_str={FUZZY_SEARCH_STR_1}",
url + f"?fuzzy_search_str={FUZZY_SEARCH_STR_4}",
headers=auth_header,
)
assert 200 == response.status_code
Expand All @@ -1360,9 +1360,9 @@ def test_fuzzy_search_bulk_privacy_requests_cache_exists(
]

# Test partial match on request id
FUZZY_SEARCH_STR_1 = privacy_request.id[:5] # use first 5 chars
FUZZY_SEARCH_STR_5 = privacy_request.id[:5] # use first 5 chars
response = api_client.get(
url + f"?fuzzy_search_str={FUZZY_SEARCH_STR_1}",
url + f"?fuzzy_search_str={FUZZY_SEARCH_STR_5}",
headers=auth_header,
)
assert 200 == response.status_code
Expand All @@ -1379,9 +1379,9 @@ def test_fuzzy_search_bulk_privacy_requests_cache_exists(
]

# Test no match on email
FUZZY_SEARCH_STR_1 = "happy" # this is invalid because it's not the beginning of the given email identity
FUZZY_SEARCH_STR_6 = "happy" # this is invalid because it's not the beginning of the given email identity
response = api_client.get(
url + f"?fuzzy_search_str={FUZZY_SEARCH_STR_1}",
url + f"?fuzzy_search_str={FUZZY_SEARCH_STR_6}",
headers=auth_header,
)
assert 200 == response.status_code
Expand Down Expand Up @@ -1432,13 +1432,6 @@ def test_fuzzy_search_privacy_requests_no_cache(
resp = response.json()
assert privacy_request.id in [result["id"] for result in resp["items"]]

# Test that the privacy request identities are automatically put in the cache as a side-effect of fuzzy-search
identities = (
privacy_request.retrieve_decrypted_identities_from_cache_by_privacy_request()
)
assert identities["email"] == TEST_EMAIL
assert identities["phone_number"] == TEST_PHONE

def test_filter_privacy_requests_by_external_id(
self,
db,
Expand Down
Loading