Skip to content

Commit

Permalink
fix: unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Bluhm <dbluhm@pm.me>
  • Loading branch information
dbluhm committed Dec 4, 2023
1 parent 4a738b3 commit 1923a5e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
2 changes: 2 additions & 0 deletions oid4vci/tests/models/test_exchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
@pytest.fixture
def record():
yield OID4VCIExchangeRecord(
state=OID4VCIExchangeRecord.STATE_OFFER_CREATED,
verification_method="did:example:123#key-1",
supported_cred_id="456",
credential_subject={"name": "alice"},
nonce="789",
Expand Down
12 changes: 11 additions & 1 deletion oid4vci/tests/routes/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@
@pytest.fixture
def context():
"""Test AdminRequestContext."""
yield AdminRequestContext.test_context()
context = AdminRequestContext.test_context()
context.update_settings({
"plugin_config": {
"oid4vci": {
"endpoint": "http://localhost:8020",
"host": "0.0.0.0",
"port": 8020,
}
}
})
yield context


@pytest.fixture
Expand Down
10 changes: 6 additions & 4 deletions oid4vci/tests/routes/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,17 @@ async def test_credential_supported_create(
return_value={
"format": "jwt_vc_json",
"id": "MyCredential",
"credentialSubject": {"name": "alice"},
"type": ["VerifiableCredential", "MyCredential"],
"format_data": {
"credentialSubject": {"name": "alice"},
"types": ["VerifiableCredential", "MyCredential"],
},
"cryptographic_binding_methods_supported": ["proof"],
"cryptographic_suites_supported": ["ES256"],
"display": [{"some nonsense": "here"}],
}
)

await test_module.credential_supported_create(req)
await test_module.supported_credential_create(req)

async with context.session() as session:
records = await SupportedCredential.query(
Expand All @@ -38,5 +40,5 @@ async def test_credential_supported_create(
assert record.identifier == "MyCredential"
assert record.format_data == {
"credentialSubject": {"name": "alice"},
"type": ["VerifiableCredential", "MyCredential"],
"types": ["VerifiableCredential", "MyCredential"],
}
6 changes: 2 additions & 4 deletions oid4vci/tests/routes/test_public_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ async def test_issuer_metadata(context: AdminRequestContext, req: web.Request):
async with context.session() as session:
await supported.save(session)

with patch.object(
test_module, "OID4VCI_ENDPOINT", "http://localhost:8020"
), patch.object(test_module, "web", autospec=True) as mock_web:
await test_module.oid_cred_issuer(req)
with patch.object(test_module, "web", autospec=True) as mock_web:
await test_module.credential_issuer_metadata(req)
mock_web.json_response.assert_called_once_with(
{
"credential_issuer": "http://localhost:8020/",
Expand Down

0 comments on commit 1923a5e

Please sign in to comment.