Esempio n. 1
0
async def test_connection_update_x_no_such_connection(web_request,
                                                      MockConnRecord):
    MockConnRecord.retrieve_by_id.side_effect = StorageNotFoundError()
    web_request.match_info = {"conn_id": "test"}
    web_request.json.return_value = {"methods": ["test"]}
    with pytest.raises(web.HTTPNotFound):
        await connection_update(web_request)
Esempio n. 2
0
 async def from_connection_id(cls, session: ProfileSession, connection_id: str):
     """Return a resolver connection from a connection id"""
     record = await ConnRecord.retrieve_by_id(session, connection_id)
     record = cast(ConnRecord, record)
     metadata = await record.metadata_get(session, DIDCommResolver.METADATA_KEY)
     if not metadata:
         raise StorageNotFoundError(
             f"Connection identified by {connection_id} is not a resolver connection"
         )
     return cls(record.connection_id, metadata["methods"])
Esempio n. 3
0
    async def test_connections_retrieve_not_found(self):
        context = RequestContext(base_context=InjectionContext(
            enforce_typing=False))
        mock_req = async_mock.MagicMock()
        mock_req.app = {
            "request_context": context,
        }
        mock_req.match_info = {"conn_id": "dummy"}

        with async_mock.patch.object(
                test_module.ConnectionRecord, "retrieve_by_id",
                async_mock.CoroutineMock()) as mock_conn_rec_retrieve_by_id:
            mock_conn_rec_retrieve_by_id.side_effect = StorageNotFoundError()

            with self.assertRaises(test_module.web.HTTPNotFound):
                await test_module.connections_retrieve(mock_req)
Esempio n. 4
0
async def test_connection_remove_x_no_such_connection(web_request,
                                                      MockConnRecord):
    MockConnRecord.retrieve_by_id.side_effect = StorageNotFoundError()
    web_request.match_info = {"conn_id": "test"}
    with pytest.raises(web.HTTPNotFound):
        await connection_remove(web_request)