From 00c3f0f0369481d20a00da997ba56cb632887ee1 Mon Sep 17 00:00:00 2001 From: ff137 Date: Mon, 19 Aug 2024 19:50:32 +0300 Subject: [PATCH] :white_check_mark: re-add assertion that pagination returns unique records across pages --- .../e2e/issuer/test_get_records_paginated.py | 35 +++++++++---------- app/tests/e2e/test_connections.py | 35 +++++++++---------- app/tests/e2e/test_tenants.py | 25 +++++++------ .../verifier/test_get_records_paginated.py | 31 ++++++++-------- 4 files changed, 61 insertions(+), 65 deletions(-) diff --git a/app/tests/e2e/issuer/test_get_records_paginated.py b/app/tests/e2e/issuer/test_get_records_paginated.py index 5f230666be..0aa4626c5a 100644 --- a/app/tests/e2e/issuer/test_get_records_paginated.py +++ b/app/tests/e2e/issuer/test_get_records_paginated.py @@ -81,24 +81,23 @@ async def test_get_credential_exchange_records_paginated( assert len(credentials) == 0 # Test fetching unique records with pagination - # TODO: Skipping for now; we require ACA-Py / Askar record ordering to guarantee unique records across pages - # prev_credentials = [] - # for offset in range(num_credentials_to_test): - # response = await faber_client.get( - # CREDENTIALS_BASE_PATH, - # params={ - # "state": "offer-sent", - # "limit": 1, - # "offset": offset, - # }, - # ) - - # credentials = response.json() - # assert len(credentials) == 1 - - # record = credentials[0] - # assert record not in prev_credentials - # prev_credentials.append(record) + prev_credentials = [] + for offset in range(num_credentials_to_test): + response = await faber_client.get( + CREDENTIALS_BASE_PATH, + params={ + "state": "offer-sent", + "limit": 1, + "offset": offset, + }, + ) + + credentials = response.json() + assert len(credentials) == 1 + + record = credentials[0] + assert record not in prev_credentials + prev_credentials.append(record) # Test invalid limit and offset values invalid_params = [ diff --git a/app/tests/e2e/test_connections.py b/app/tests/e2e/test_connections.py index 22f8d6d9b2..bbd4c525ed 100644 --- a/app/tests/e2e/test_connections.py +++ b/app/tests/e2e/test_connections.py @@ -298,24 +298,23 @@ async def test_get_connections_paginated( assert len(connections) == 0 # Test fetching unique records with pagination - # TODO: Skipping for now; we require ACA-Py / Askar record ordering to guarantee unique records across pages - # prev_connections = [] - # for offset in range(num_connections_to_test): - # response = await alice_member_client.get( - # BASE_PATH, - # params={ - # "alias": test_alias, - # "limit": 1, - # "offset": offset, - # }, - # ) - - # connections = response.json() - # assert len(connections) == 1 - - # record = connections[0] - # assert record not in prev_connections - # prev_connections += (record,) + prev_connections = [] + for offset in range(num_connections_to_test): + response = await alice_member_client.get( + BASE_PATH, + params={ + "alias": test_alias, + "limit": 1, + "offset": offset, + }, + ) + + connections = response.json() + assert len(connections) == 1 + + record = connections[0] + assert record not in prev_connections + prev_connections += (record,) # Test invalid limit and offset values invalid_params = [ diff --git a/app/tests/e2e/test_tenants.py b/app/tests/e2e/test_tenants.py index 952cff893e..2ed42e47b0 100644 --- a/app/tests/e2e/test_tenants.py +++ b/app/tests/e2e/test_tenants.py @@ -918,19 +918,18 @@ async def test_get_wallets_paginated(tenant_admin_client: RichAsyncClient): assert len(wallets) == 0 # Test fetching unique records with pagination - # TODO: Skipping for now; we require ACA-Py / Askar record ordering to guarantee unique records across pages - # prev_wallets = [] - # for offset in range(num_wallets_to_test): - # response = await tenant_admin_client.get( - # f"{TENANTS_BASE_PATH}?limit=1&offset={offset}&group_id={test_group}" - # ) - - # wallets = response.json() - # assert len(wallets) == 1 - - # wallet = wallets[0] - # assert wallet not in prev_wallets - # prev_wallets.append(wallet) + prev_wallets = [] + for offset in range(num_wallets_to_test): + response = await tenant_admin_client.get( + f"{TENANTS_BASE_PATH}?limit=1&offset={offset}&group_id={test_group}" + ) + + wallets = response.json() + assert len(wallets) == 1 + + wallet = wallets[0] + assert wallet not in prev_wallets + prev_wallets.append(wallet) # Test invalid limit and offset values invalid_params = [ diff --git a/app/tests/e2e/verifier/test_get_records_paginated.py b/app/tests/e2e/verifier/test_get_records_paginated.py index 054836a393..434b317179 100644 --- a/app/tests/e2e/verifier/test_get_records_paginated.py +++ b/app/tests/e2e/verifier/test_get_records_paginated.py @@ -75,24 +75,23 @@ async def test_get_presentation_exchange_records_paginated( assert len(proofs) == 0 # Test fetching unique records with pagination - # TODO: Skipping for now; we require ACA-Py / Askar record ordering to guarantee unique records across pages - # prev_proofs = [] - # for offset in range(num_presentation_requests_to_test): - # response = await acme_client.get( - # f"{VERIFIER_BASE_PATH}/proofs", - # params={ - # "state": "request-sent", - # "limit": 1, - # "offset": offset, - # }, - # ) + prev_proofs = [] + for offset in range(num_presentation_requests_to_test): + response = await acme_client.get( + f"{VERIFIER_BASE_PATH}/proofs", + params={ + "state": "request-sent", + "limit": 1, + "offset": offset, + }, + ) - # proofs = response.json() - # assert len(proofs) == 1 + proofs = response.json() + assert len(proofs) == 1 - # record = proofs[0] - # assert record not in prev_proofs - # prev_proofs.append(record) + record = proofs[0] + assert record not in prev_proofs + prev_proofs.append(record) # Test invalid limit and offset values invalid_params = [