def setUp(self): self.master = fakemaster.make_master(testcase=self, wantData=True, wantDb=True, wantMq=True) self.message = message.MessageFormatter()
def test_message_success_plain_no_steps(self): formatter = message.MessageFormatter() res = yield self.do_one_test(formatter, SUCCESS, SUCCESS) self.assertEqual( res, { 'type': 'plain', 'subject': '☺ Buildbot (Buildbot): Builder1 - test ((unknown revision))', 'body': textwrap.dedent('''\ A passing build has been detected on builder Builder1 while building Buildbot. Full details are available at: http://localhost:8080/#builders/80/builds/1 Build state: test Revision: (unknown) Worker: wrkr Build Reason: because Blamelist: him@bar, me@foo Steps: - (no steps) ''') })
def test_message_success_html(self): formatter = message.MessageFormatter(template_type='html') res = yield self.do_one_test(formatter, SUCCESS, SUCCESS) self.assertEqual( res, { 'type': 'html', 'subject': '☺ Buildbot (Buildbot): Builder1 - test ((unknown revision))', 'body': textwrap.dedent('''\ <p>A passing build has been detected on builder <a href="http://localhost:8080/#builders/80/builds/1">Builder1</a> while building Buildbot.</p> <p>Information:</p> <ul> <li>Build state: test</li> <li>Revision: (unknown)</li> <li>Worker: wrkr</li> <li>Build Reason: because</li> <li>Blamelist: him@bar, me@foo</li> </ul> <p>Steps:</p> <ul> <li>No steps</li> </ul>''') })
def setUp(self): self.setUpTestReactor() self.master = fakemaster.make_master(self, wantData=True, wantDb=True, wantMq=True) self.message = message.MessageFormatter() self.messageMissing = message.MessageFormatterMissingWorker()
def test_inline_template(self): self.message = message.MessageFormatter( template="URL: {{ build_url }} -- {{ summary }}") res = yield self.doOneTest(SUCCESS, SUCCESS) self.assertEqual(res['type'], "plain") self.assertEqual( res['body'], "URL: http://localhost:8080/#builders/80/builds/1 -- Build succeeded!" )
def test_message_success_html_with_steps(self): formatter = message.MessageFormatter(template_type='html') res = yield self.do_one_test( formatter, SUCCESS, SUCCESS, with_steps=True, extra_build_properties={'got_revision': 'abcd1234'}) self.assertEqual( res, { 'type': 'html', 'subject': '☺ Buildbot (Buildbot): Builder1 - test (abcd1234)', 'body': textwrap.dedent('''\ <p>A passing build has been detected on builder <a href="http://localhost:8080/#builders/80/builds/1">Builder1</a> while building Buildbot.</p> <p>Information:</p> <ul> <li>Build state: test</li> <li>Revision: abcd1234</li> <li>Worker: wrkr</li> <li>Build Reason: because</li> <li>Blamelist: him@bar, me@foo</li> </ul> <p>Steps:</p> <ul> <li style=""> 1: first step ( success ) </li> <li style=""> 2: second step ( success ) ( <a href="http://localhost:8080/#builders/80/builds/1/steps/2/logs/stdio"><stdio></a> <a href="http://localhost:8080/#builders/80/builds/1/steps/2/logs/stderr"><stderr></a> ) </li> <li style=""> 3: third step ( success ) ( <a href="http://localhost:8080/#builders/80/builds/1/steps/3/logs/stdio"><stdio></a> ) </li> </ul>''') # noqa pylint: disable=line-too-long })
def test_message_success_plain_with_steps(self): formatter = message.MessageFormatter() res = yield self.do_one_test( formatter, SUCCESS, SUCCESS, with_steps=True, extra_build_properties={'got_revision': 'abcd1234'}) self.assertEqual( res, { 'type': 'plain', 'subject': '☺ Buildbot (Buildbot): Builder1 - test (abcd1234)', 'body': textwrap.dedent('''\ A passing build has been detected on builder Builder1 while building Buildbot. Full details are available at: http://localhost:8080/#builders/80/builds/1 Build state: test Revision: abcd1234 Worker: wrkr Build Reason: because Blamelist: him@bar, me@foo Steps: - 1: first step ( success ) - 2: second step ( success ) Logs: - stdio: http://localhost:8080/#builders/80/builds/1/steps/2/logs/stdio - stderr: http://localhost:8080/#builders/80/builds/1/steps/2/logs/stderr - 3: third step ( success ) Logs: - stdio: http://localhost:8080/#builders/80/builds/1/steps/3/logs/stdio ''') })
def test_message_success(self): formatter = message.MessageFormatter() res = yield self.do_one_test(formatter, SUCCESS, SUCCESS) self.assertEqual(res['type'], "plain") self.assertEqual( res['body'], textwrap.dedent('''\ The Buildbot has detected a passing build on builder Builder1 while building Buildbot. Full details are available at: http://localhost:8080/#builders/80/builds/1 Buildbot URL: http://localhost:8080/ Worker for this Build: wrkr Build Reason: because Blamelist: him@bar, me@foo Build succeeded! Sincerely, -The Buildbot''')) self.assertIsNone(res['subject'])
def test_message_failure_nochange(self): formatter = message.MessageFormatter() res = yield self.do_one_test(formatter, FAILURE, FAILURE, "change") self.assertIn("The Buildbot has detected a failed build on builder", res['body'])
def test_inline_subject(self): self.message = message.MessageFormatter(subject="subject") res = yield self.doOneTest(SUCCESS, SUCCESS) self.assertEqual(res['subject'], "subject")
def test_want_logs_deprecated(self): with assertProducesWarning(DeprecatedApiWarning, "wantLogs has been deprecated"): formatter = message.MessageFormatter(wantLogs=True) self.assertEqual(formatter.want_logs, True) self.assertEqual(formatter.want_logs_content, True)
def test_want_steps_deprecated(self): with assertProducesWarning(DeprecatedApiWarning, "wantSteps has been deprecated"): formatter = message.MessageFormatter(wantSteps=True) self.assertEqual(formatter.want_steps, True)
def test_message_failure_nochange(self): formatter = message.MessageFormatter() res = yield self.do_one_test(formatter, FAILURE, FAILURE, "change") self.assertIn( "A failed build has been detected on builder Builder1 while building", res['body'])
def test_message_success_nochange(self): formatter = message.MessageFormatter() res = yield self.do_one_test(formatter, SUCCESS, SUCCESS, "change") self.assertIn( "A passing build has been detected on builder Builder1 while building", res['body'])
def test_inline_subject(self): formatter = message.MessageFormatter(subject="subject") res = yield self.do_one_test(formatter, SUCCESS, SUCCESS) self.assertEqual(res['subject'], "subject")
def test_unknown_template_type_for_default_message(self): with self.assertRaises(config.ConfigErrors): message.MessageFormatter(template_type='unknown')
def test_message_success_nochange(self): formatter = message.MessageFormatter() res = yield self.do_one_test(formatter, SUCCESS, SUCCESS, "change") self.assertIn("The Buildbot has detected a passing build on builder", res['body'])