Skip to content

Commit

Permalink
adapt tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Archento committed Aug 27, 2024
1 parent 57ad5c2 commit 14217b4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
2 changes: 1 addition & 1 deletion python/tests/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ async def _(_ctx: Context, req: Request):
call(
{
"type": "http.response.body",
"body": b'[\n {\n "loc": [\n "text"\n ],\n "msg": "field required",\n "type": "value_error.missing"\n }\n]', # noqa: E501
"body": b'{"loc": ["text"], "msg": "field required", "type": "value_error.missing"}', # noqa: E501
}
),
]
Expand Down
27 changes: 9 additions & 18 deletions python/tests/test_server.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# pylint: disable=protected-access
import asyncio
import json
import unittest
import uuid
from unittest.mock import AsyncMock, call, patch
Expand Down Expand Up @@ -62,13 +63,7 @@ async def test_message_success(self):
"status": 200,
"headers": [[b"content-type", b"application/json"]],
}
),
call(
{
"type": "http.response.body",
"body": b"{}",
}
),
)
]
)

Expand Down Expand Up @@ -106,13 +101,7 @@ async def test_message_success_unsigned(self):
"status": 200,
"headers": [[b"content-type", b"application/json"]],
}
),
call(
{
"type": "http.response.body",
"body": b"{}",
}
),
)
]
)

Expand Down Expand Up @@ -151,6 +140,7 @@ async def test_message_success_sync_unsigned(self):
asyncio.create_task(self.mock_process_sync_message(user, reply)),
)
response = enclose_response(reply, self.agent.address, session, user)
formatted = json.loads(response)
mock_send.assert_has_calls(
[
call(
Expand All @@ -163,7 +153,7 @@ async def test_message_success_sync_unsigned(self):
call(
{
"type": "http.response.body",
"body": response.encode(),
"body": json.dumps(formatted).encode(),
}
),
]
Expand Down Expand Up @@ -208,6 +198,7 @@ async def test_message_success_sync_signed(self):
response = enclose_response(
reply, self.agent.address, session, self.bob.address
)
formatted = json.loads(response)
mock_send.assert_has_calls(
[
call(
Expand All @@ -220,7 +211,7 @@ async def test_message_success_sync_signed(self):
call(
{
"type": "http.response.body",
"body": response.encode(),
"body": json.dumps(formatted).encode(),
}
),
]
Expand Down Expand Up @@ -381,7 +372,7 @@ async def test_message_fail_unsigned(self):
call(
{
"type": "http.response.body",
"body": b'{"error": "signature verification failed"}',
"body": b'{"error": "Envelope signature is missing"}',
}
),
]
Expand Down Expand Up @@ -424,7 +415,7 @@ async def test_message_fail_verify(self):
call(
{
"type": "http.response.body",
"body": b'{"error": "signature verification failed"}',
"body": b'{"error": "Signature verification failed"}',
}
),
]
Expand Down

0 comments on commit 14217b4

Please sign in to comment.