Exemple #1
0
 def test_list_error_message(self):
     report = self.session.query(ReportStore).first()
     TaskErrorStore.add('report', report.id, 'message', 'traceback')
     response = self.client.get('/reports/list/')
     reports = json.loads(response.data)['reports']
     assert_equal(reports[0]['error_message'], 'message')
     assert_equal(reports[1]['error_message'], None)
 def test_list_error_message(self):
     report = self.session.query(ReportStore).first()
     TaskErrorStore.add('report', report.id, 'message', 'traceback')
     response = self.client.get('/reports/list/')
     reports = json.loads(response.data)['reports']
     assert_equal(reports[0]['error_message'], 'message')
     assert_equal(reports[1]['error_message'], None)
 def test_add_new(self):
     # If the failing report has no previous errors,
     # a new task error should be created.
     t1 = datetime.now().replace(microsecond=0)
     TaskErrorStore.add('report', self.report.id, 'message', 'traceback')
     t2 = datetime.now().replace(microsecond=0)
     row = self.session.query(TaskErrorStore).first()
     assert_equal(row.task_type, 'report')
     assert_equal(row.task_id, self.report.id)
     assert_true(row.timestamp >= t1 and row.timestamp <= t2)
     assert_equal(row.message, 'message')
     assert_equal(row.traceback, 'traceback')
     assert_equal(row.count, 1)
 def test_add_new(self):
     # If the failing report has no previous errors,
     # a new task error should be created.
     t1 = datetime.now().replace(microsecond=0)
     TaskErrorStore.add("report", self.report.id, "message", "traceback")
     t2 = datetime.now().replace(microsecond=0)
     row = self.session.query(TaskErrorStore).first()
     assert_equal(row.task_type, "report")
     assert_equal(row.task_id, self.report.id)
     assert_true(row.timestamp >= t1 and row.timestamp <= t2)
     assert_equal(row.message, "message")
     assert_equal(row.traceback, "traceback")
     assert_equal(row.count, 1)
 def test_add_existing(self):
     # If the failing report has previous errors,
     # the existing task error should be updated.
     t1 = datetime.now()
     te = TaskErrorStore(
         task_type="report", task_id=self.report.id, count=1, timestamp=t1, message="message", traceback="traceback"
     )
     self.session.add(te)
     self.session.commit()
     TaskErrorStore.add("report", self.report.id, "message2", "traceback2")
     t2 = datetime.now()
     row = self.session.query(TaskErrorStore).first()
     print t1, row.timestamp, t2
     assert_equal(row.task_type, "report")
     assert_equal(row.task_id, self.report.id)
     assert_true(row.timestamp > t1 and row.timestamp < t2)
     assert_equal(row.message, "message2")
     assert_equal(row.traceback, "traceback2")
     assert_equal(row.count, 2)
 def test_task_error_repr(self):
     pr = ReportStore(status=celery.states.PENDING)
     self.session.add(pr)
     self.session.commit()
     te = TaskErrorStore(task_type='report',
                         task_id=pr.id,
                         message='m',
                         traceback='t',
                         count=1)
     self.session.add(te)
     self.session.commit()
     row = self.session.query(TaskErrorStore).first()
     assert_true(str(row).find('TaskErrorStore') >= 0)
 def test_add_existing(self):
     # If the failing report has previous errors,
     # the existing task error should be updated.
     t1 = datetime.now()
     te = TaskErrorStore(task_type='report',
                         task_id=self.report.id,
                         count=1,
                         timestamp=t1,
                         message='message',
                         traceback='traceback')
     self.session.add(te)
     self.session.commit()
     TaskErrorStore.add('report', self.report.id, 'message2', 'traceback2')
     t2 = datetime.now()
     row = self.session.query(TaskErrorStore).first()
     print t1, row.timestamp, t2
     assert_equal(row.task_type, 'report')
     assert_equal(row.task_id, self.report.id)
     assert_true(row.timestamp > t1 and row.timestamp < t2)
     assert_equal(row.message, 'message2')
     assert_equal(row.traceback, 'traceback2')
     assert_equal(row.count, 2)
 def test_task_error(self):
     pr = ReportStore(status=celery.states.PENDING)
     self.session.add(pr)
     self.session.commit()
     te = TaskErrorStore(task_type='report',
                         task_id=pr.id,
                         message='m',
                         traceback='t',
                         count=1)
     self.session.add(te)
     self.session.commit()
     row = self.session.query(TaskErrorStore).first()
     assert_equal(row.task_type, 'report')
     assert_equal(row.task_id, pr.id)
     assert_equal(row.message, 'm')
     assert_equal(row.traceback, 't')
     assert_equal(row.count, 1)