Пример #1
0
 def test_notify(self):
     l = Listener()
     reply = Started(document)
     reply.notify(l)
     l.started.assert_called_once_with(reply)
     f = Mock()
     reply.notify(f)
     f.assert_called_once_with(reply)
Пример #2
0
    def test_started(self, mock_task_started):
        task_id = 'task_1'
        call_context = {
            'task_id': task_id,
        }
        document = Document(routing=['A', 'B'], any=call_context)
        reply = Started(document)
        handler = self.reply_handler()
        handler.started(reply)

        # validate task updated
        mock_task_started.assert_called_with(task_id)
Пример #3
0
 def test_notify(self):
     l = Listener()
     reply = Started(document)
     reply.notify(l)
     l.started.assert_called_once_with(reply)
     f = Mock()
     reply.notify(f)
     f.assert_called_once_with(reply)
Пример #4
0
    def test_started(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'], any=call_context)
        reply = Started(document)
        handler = self.reply_handler()
        handler.started(reply)

        # validate task updated
        mock_task_objects.assert_called_with(task_id=task_id,
                                             state__in=[constants.CALL_WAITING_STATE,
                                                        constants.CALL_ACCEPTED_STATE])
        mock_returned_tasks.update_one.assert_called_with(set__state=constants.CALL_RUNNING_STATE)
Пример #5
0
 def test_str(self):
     reply = Started(document)
     s = str(reply)
     self.assertTrue(isinstance(s, str))
Пример #6
0
 def test_init(self):
     reply = Started(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)