示例#1
0
 def test_notify(self):
     l = Listener()
     reply = Progress(document)
     reply.notify(l)
     l.progress.assert_called_once_with(reply)
     f = Mock()
     reply.notify(f)
     f.assert_called_once_with(reply)
示例#2
0
 def test_init(self):
     reply = Progress(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)
     self.assertEqual(reply.total, document.total)
     self.assertEqual(reply.completed, document.completed)
     self.assertEqual(reply.details, document.details)
示例#3
0
 def test_notify(self):
     l = Listener()
     reply = Progress(document)
     reply.notify(l)
     l.progress.assert_called_once_with(reply)
     f = Mock()
     reply.notify(f)
     f.assert_called_once_with(reply)
示例#4
0
    def test_progress_reported(self, mock_task_objects):
        task_id = 'task_1'
        call_context = {'task_id': task_id}
        progress_report = {'step': 'step-1'}
        test_task_documents = Mock()
        mock_task_objects.return_value = test_task_documents
        document = Document(routing=['A', 'B'], any=call_context, details=progress_report)
        reply = Progress(document)
        handler = self.reply_handler()
        handler.progress(reply)

        # validate task updated
        mock_task_objects.assert_called_with(task_id=task_id)
        test_task_documents.update_one.assert_called_with(set__progress_report=progress_report)
示例#5
0
    def test_progress_reported(self, mock_update_task_status):
        task_id = 'task_1'
        call_context = {'task_id': task_id}
        progress_report = {'step': 'step-1'}
        document = Document(routing=['A', 'B'],
                            any=call_context,
                            details=progress_report)
        reply = Progress(document)
        handler = self.reply_handler()
        handler.progress(reply)

        # validate task updated
        delta = {'progress_report': progress_report}
        mock_update_task_status.assert_called_with(task_id, delta)
示例#6
0
 def test_str(self):
     reply = Progress(document)
     s = str(reply)
     self.assertTrue(isinstance(s, str))