Source code for aries_cloudagent.messaging.routing.messages.tests.test_route_query_response

from ..route_query_response import RouteQueryResponse
from ...message_types import ROUTE_QUERY_RESPONSE
from ...models.paginated import Paginated, PaginatedSchema
from ...models.route_record import RouteRecord

from unittest import mock, TestCase


[docs]class TestRouteQueryResponse(TestCase): test_start = 10 test_end = 15 test_limit = 5 test_total = 20 test_verkey = "3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRx" test_route_id = "route-id" test_conn_id = "conn-id"
[docs] def setUp(self): self.paginated = Paginated( start=self.test_start, end=self.test_end, limit=self.test_limit, total=self.test_total, ) self.record = RouteRecord( record_id=self.test_route_id, connection_id=self.test_conn_id, recipient_key=self.test_verkey, ) self.message = RouteQueryResponse( routes=[self.record], paginated=self.paginated )
[docs] def test_init(self): assert len(self.message.routes) == 1 assert self.message.routes[0].record_id == self.test_route_id assert self.message.routes[0].connection_id == self.test_conn_id assert self.message.routes[0].recipient_key == self.test_verkey assert self.message.paginated.start == self.test_start assert self.message.paginated.end == self.test_end assert self.message.paginated.limit == self.test_limit assert self.message.paginated.total == self.test_total
[docs] def test_type(self): assert self.message._type == ROUTE_QUERY_RESPONSE
[docs] @mock.patch( "aries_cloudagent.messaging.routing.messages.route_query_response.RouteQueryResponseSchema.load" ) def test_deserialize(self, message_schema_load): obj = {"obj": "obj"} message = RouteQueryResponse.deserialize(obj) message_schema_load.assert_called_once_with(obj) assert message is message_schema_load.return_value
[docs] @mock.patch( "aries_cloudagent.messaging.routing.messages.route_query_response.RouteQueryResponseSchema.dump" ) def test_serialize(self, message_schema_dump): message_dict = self.message.serialize() message_schema_dump.assert_called_once_with(self.message) assert message_dict is message_schema_dump.return_value
[docs]class TestRouteQueryResponseSchema(TestCase):
[docs] def test_make_model(self): message = RouteQueryResponse( routes=[RouteRecord(record_id="a", connection_id="b", recipient_key="c")], paginated=Paginated(), ) data = message.serialize() model_instance = RouteQueryResponse.deserialize(data) assert isinstance(model_instance, RouteQueryResponse)