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)
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)
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)
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)
def test_str(self): reply = Progress(document) s = str(reply) self.assertTrue(isinstance(s, str))