コード例 #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)
コード例 #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)
コード例 #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)
コード例 #4
0
ファイル: test_tasks.py プロジェクト: Linaro/squad
 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)
コード例 #5
0
ファイル: test_tasks.py プロジェクト: Linaro/squad
 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)
コード例 #6
0
ファイル: test_tasks.py プロジェクト: Linaro/squad
 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)
コード例 #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)
コード例 #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)
コード例 #9
0
 def test_invalid_id(self):
     report = prepare_report(999)
     self.assertIsNone(report)
コード例 #10
0
ファイル: test_tasks.py プロジェクト: Linaro/squad
 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)
コード例 #11
0
ファイル: test_tasks.py プロジェクト: Linaro/squad
 def test_invalid_id(self):
     report = prepare_report(999)
     self.assertIsNone(report)