Skip to content

Commit

Permalink
✅ fix test to work with pytest-xdist (#986)
Browse files Browse the repository at this point in the history
* ✅ fix test to work with pytest-xdist

* ✅ add short sleep before asserting record is deleted (#957)

* 🎨
  • Loading branch information
ff137 authored Aug 16, 2024
1 parent 6ad2a0a commit 48b9ac6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
4 changes: 1 addition & 3 deletions app/tests/e2e/issuer/test_save_exchange_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@ async def test_issue_credential_with_save_exchange_record(
},
)

time.sleep(
1
) # short sleep before fetching cred ex records; allow them to update
await asyncio.sleep(1) # short sleep before fetching; allow records to update

# faber requesting auto_remove only removes their cred ex records
# get exchange record from alice side -- should not exist after complete
Expand Down
19 changes: 14 additions & 5 deletions app/tests/e2e/test_wallet_dids.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,23 @@ async def create_did_mock(governance_client: RichAsyncClient):
async def test_list_dids(
governance_client: RichAsyncClient, mock_governance_auth: AcaPyAuthVerified
):
response = await governance_client.get(WALLET_BASE_PATH)
# Capture the existing DIDs before the request
initial_dids = await list_dids(auth=mock_governance_auth)
initial_dids_set = set(map(lambda x: x.did, initial_dids))

# Make the GET request
response = await governance_client.get(WALLET_BASE_PATH)
assert response.status_code == 200
response = response.json()
response_data = response.json()

# Filter the response to include only the initial DIDs
filtered_response_data = [
did_dict for did_dict in response_data if did_dict["did"] in initial_dids_set
]

res_method: List[DID] = await list_dids(auth=mock_governance_auth)
res_method_dict = list(map(lambda x: x.to_dict(), res_method))
assert res_method_dict == response
# Compare the filtered response with the initial DIDs
initial_dids_dict = list(map(lambda x: x.to_dict(), initial_dids))
assert filtered_response_data == initial_dids_dict


@pytest.mark.anyio
Expand Down
12 changes: 6 additions & 6 deletions app/tests/e2e/verifier/test_verifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,11 @@ async def test_saving_of_presentation_exchange_records(
VERIFIER_BASE_PATH + "/accept-request",
json=proof_accept.model_dump(),
)
result = response.json()

pres_exchange_result = PresentationExchange(**result)
assert isinstance(pres_exchange_result, PresentationExchange)
assert response.status_code == 200

await assert_both_webhooks_received(
alice_member_client,
Expand All @@ -640,12 +645,7 @@ async def test_saving_of_presentation_exchange_records(
acme_proof_id,
)

result = response.json()

pres_exchange_result = PresentationExchange(**result)
assert isinstance(pres_exchange_result, PresentationExchange)
assert response.status_code == 200

await asyncio.sleep(1) # short sleep before fetching records; allow them to update
# get exchange records from alice side
if alice_save_exchange_record:
# Save record is True, should be 1 record
Expand Down

0 comments on commit 48b9ac6

Please sign in to comment.