diff --git a/python/tests/test_rest.py b/python/tests/test_rest.py index 701b1fc3..bf0c45e5 100644 --- a/python/tests/test_rest.py +++ b/python/tests/test_rest.py @@ -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 } ), ] diff --git a/python/tests/test_server.py b/python/tests/test_server.py index 7a819f41..904a6ff2 100644 --- a/python/tests/test_server.py +++ b/python/tests/test_server.py @@ -1,5 +1,6 @@ # pylint: disable=protected-access import asyncio +import json import unittest import uuid from unittest.mock import AsyncMock, call, patch @@ -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"{}", - } - ), + ) ] ) @@ -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"{}", - } - ), + ) ] ) @@ -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( @@ -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(), } ), ] @@ -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( @@ -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(), } ), ] @@ -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"}', } ), ] @@ -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"}', } ), ]