Skip to content

Commit

Permalink
Update unit test
Browse files Browse the repository at this point in the history
Signed-off-by: jamshale <jamiehalebc@gmail.com>
  • Loading branch information
jamshale committed Dec 19, 2024
1 parent 45bcf4a commit 1415546
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 0 additions & 5 deletions acapy_agent/anoncreds/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,6 @@ async def schemas_post(request: web.BaseRequest):
name = schema_data.get("name")
version = schema_data.get("version")

if not issuer_id or not attr_names or not name or not version:
raise web.HTTPBadRequest(
reason="issuerId, attrNames, name, and version are required"
)

try:
issuer = AnonCredsIssuer(profile)
result = await issuer.create_and_register_schema(
Expand Down
14 changes: 12 additions & 2 deletions acapy_agent/anoncreds/tests/test_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ async def test_schemas_post(self, mock_create_and_register_schema):
},
{},
{"schema": {}},
{
"schema": {
"attrNames": ["score"],
"name": "Example Schema",
"version": "0.0.1",
}
},
]
)
result = await test_module.schemas_post(self.request)
Expand All @@ -105,9 +112,12 @@ async def test_schemas_post(self, mock_create_and_register_schema):
assert mock_create_and_register_schema.call_count == 1

with self.assertRaises(web.HTTPBadRequest):
# Empty body
await test_module.schemas_post(self.request)
# Empty schema
await test_module.schemas_post(self.request)
# Missing issuerId
await test_module.schemas_post(self.request)

await test_module.schemas_post(self.request)

async def test_get_schema(self):
self.request.match_info = {"schema_id": "schema_id"}
Expand Down

0 comments on commit 1415546

Please sign in to comment.