Ejemplo n.º 1
0
 async def onClose(self, wasClean, code, reason):
     log.info('Connection was closed. Reason: %s, peer: %s', reason,
              self.peer)
     await self.supervisor.handle_message(
         sender=self,
         peer=self.peer,
         message=IncomingMessage(path='worker_disconnected'),
     )
Ejemplo n.º 2
0
    async def test_when_input_matches_schema_no_error_should_be_raised(self):
        data = {'work_id': 1, 'status': 'DONE', 'output': 'some output'}
        request = Request(
            message=IncomingMessage(path='something', body=data),
            sender=Mock(),
            peer=Mock(),
        )

        result = await SomeClass().method(request)

        assert result == data
Ejemplo n.º 3
0
    async def test_input_does_not_match_schema_error_should_be_raised(self):
        request = Request(
            message=IncomingMessage(
                path='lala',
                body={},
            ),
            sender=Mock(),
            peer=Mock(),
        )
        with pytest.raises(exceptions.ValidationError) as exc:
            await SomeClass().method(request)

        assert exc.value.data == {
            'work_id': ['This field is required.'],
            'status': ['This field is required.'],
        }
Ejemplo n.º 4
0
 def get_message(self, message_body=None):
     return IncomingMessage(
         path=self.PATH,
         body=message_body
     )