def test_notify(self): l = Listener() reply = Accepted(document) reply.notify(l) l.accepted.assert_called_once_with(reply) f = Mock() reply.notify(f) f.assert_called_once_with(reply)
def test_accepted(self, mock_task_accepted): task_id = 'task_1' call_context = {'task_id': task_id} document = Document(routing=['A', 'B'], any=call_context) reply = Accepted(document) handler = self.reply_handler() handler.accepted(reply) # validate task updated mock_task_accepted.assert_called_with(task_id)
def test_accepted(self, mock_task_objects): task_id = 'task_1' call_context = {'task_id': task_id} mock_returned_tasks = Mock() mock_task_objects.return_value = mock_returned_tasks document = Document(routing=['A', 'B'], data=call_context) reply = Accepted(document) handler = self.reply_handler() handler.accepted(reply) # validate task updated mock_task_objects.assert_called_once_with( task_id=task_id, state=constants.CALL_WAITING_STATE) mock_returned_tasks.update_one.assert_called_once_with( set__state=constants.CALL_ACCEPTED_STATE)
def test_str(self): reply = Accepted(document) s = str(reply) self.assertTrue(isinstance(s, str))
def test_init(self): reply = Accepted(document) self.assertEqual(reply.sn, document.sn) self.assertEqual(reply.origin, document.routing[0]) self.assertEqual(reply.timestamp, document.timestamp) self.assertEqual(reply.data, document.data)