Ejemplo n.º 1
0
 def test_long_error_message(self):
     report = self.build2.delayed_reports.create()
     prepared_report = prepare_report(report.pk)
     data = {"lineno": 1234, "message": LONG_ERROR_MESSAGE}
     update_delayed_report(prepared_report, data, 400)
     self.assertEqual(
         yaml.load(prepared_report.error_message)['message'],
         LONG_ERROR_MESSAGE)
Ejemplo n.º 2
0
 def test_callback_notification(self, callback_notification_mock):
     UpdateProjectStatus()(self.testrun)
     UpdateProjectStatus()(self.testrun2)
     report = self.build2.delayed_reports.create()
     report.callback = "http://foo.bar.com"
     report.save()
     prepared_report = prepare_report(report.pk)
     self.assertEqual(200, prepared_report.status_code)
     callback_notification_mock.assert_called_with(report.pk)
Ejemplo n.º 3
0
 def test_email_notification(self, email_notification_mock):
     UpdateProjectStatus()(self.testrun)
     UpdateProjectStatus()(self.testrun2)
     report = self.build2.delayed_reports.create()
     report.email_recipient = "*****@*****.**"
     report.save()
     prepared_report = prepare_report(report.pk)
     self.assertEqual(200, prepared_report.status_code)
     email_notification_mock.assert_called_with(report.pk)
Ejemplo n.º 4
0
 def test_callback_notification(self, callback_notification_mock):
     UpdateProjectStatus()(self.testrun)
     UpdateProjectStatus()(self.testrun2)
     report = self.build2.delayed_reports.create()
     report.callback = "http://foo.bar.com"
     report.save()
     prepared_report = prepare_report(report.pk)
     self.assertEqual(200, prepared_report.status_code)
     callback_notification_mock.assert_called_with(report.pk)
Ejemplo n.º 5
0
 def test_email_notification(self, email_notification_mock):
     UpdateProjectStatus()(self.testrun)
     UpdateProjectStatus()(self.testrun2)
     report = self.build2.delayed_reports.create()
     report.email_recipient = "*****@*****.**"
     report.save()
     prepared_report = prepare_report(report.pk)
     self.assertEqual(200, prepared_report.status_code)
     email_notification_mock.assert_called_with(report.pk)
Ejemplo n.º 6
0
 def test_long_error_message(self):
     report = self.build2.delayed_reports.create()
     prepared_report = prepare_report(report.pk)
     data = {
         "lineno": 1234,
         "message": LONG_ERROR_MESSAGE
     }
     update_delayed_report(prepared_report, data, 400)
     self.assertEqual(yaml.load(prepared_report.error_message)['message'], LONG_ERROR_MESSAGE)
Ejemplo n.º 7
0
 def email(self, request, pk=None):
     """
     This method produces the body of email notification for the build.
     By default it uses the project settings for HTML and template.
     These settings can be overwritten by using GET parameters:
      * output - sets the output format (text/plan, text/html)
      * template - sets the template used (id of existing template or
                   "default" for default SQUAD templates)
      * force - force email report re-generation even if there is
                existing one cached
     """
     force = request.query_params.get("force", False)
     delayed_report, created = self.__return_delayed_report(request)
     if created or force:
         delayed_report = prepare_report(delayed_report.pk)
     if delayed_report.status_code != status.HTTP_200_OK:
         return Response(yaml.safe_load(delayed_report.error_message or ''), delayed_report.status_code)
     if delayed_report.output_format == "text/html" and delayed_report.output_html:
         return HttpResponse(delayed_report.output_html, content_type=delayed_report.output_format)
     return HttpResponse(delayed_report.output_text, content_type=delayed_report.output_format)
Ejemplo n.º 8
0
 def test_prepare_report(self):
     UpdateProjectStatus()(self.testrun)
     UpdateProjectStatus()(self.testrun2)
     report = self.build2.delayed_reports.create()
     prepared_report = prepare_report(report.pk)
     self.assertEqual(200, prepared_report.status_code)
Ejemplo n.º 9
0
 def test_invalid_id(self):
     report = prepare_report(999)
     self.assertIsNone(report)
Ejemplo n.º 10
0
 def test_prepare_report(self):
     UpdateProjectStatus()(self.testrun)
     UpdateProjectStatus()(self.testrun2)
     report = self.build2.delayed_reports.create()
     prepared_report = prepare_report(report.pk)
     self.assertEqual(200, prepared_report.status_code)
Ejemplo n.º 11
0
 def test_invalid_id(self):
     report = prepare_report(999)
     self.assertIsNone(report)