# HG changeset patch # User osimons # Date 1284642144 0 # Node ID ae3b946b770413f5a84807375bd7c36fffd557da # Parent 3a298b4963a7059755ec164c6e1bf10cbda755d1 0.6dev: Merged [902] from trunk. diff --git a/bitten/notify.py b/bitten/notify.py --- a/bitten/notify.py +++ b/bitten/notify.py @@ -6,8 +6,9 @@ # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. +from genshi.template.text import NewTextTemplate from trac.core import Component, implements -from trac.web.chrome import ITemplateProvider +from trac.web.chrome import ITemplateProvider, Chrome from trac.config import BoolOption from trac.notification import NotifyEmail from bitten.api import IBuildListener @@ -90,6 +91,10 @@ def __init__(self, env): NotifyEmail.__init__(self, env) + # Override the template type to always use NewTextTemplate + if not isinstance(self.template, NewTextTemplate): + self.template = Chrome(env).templates.load( + self.template.filepath, cls=NewTextTemplate) def notify(self, build): self.build = build diff --git a/bitten/templates/bitten_notify_email.txt b/bitten/templates/bitten_notify_email.txt --- a/bitten/templates/bitten_notify_email.txt +++ b/bitten/templates/bitten_notify_email.txt @@ -7,18 +7,18 @@ Build Configuration: $build.config Build Slave: $build.slave Build Number: $build.id - <${build.link}> -#if build.failed_steps +{% if build.failed_steps %}\ Failures: -#for step in build.failed_steps +{% for step in build.failed_steps %}\ Step: $step.name Errors: ${', '.join(step.errors)} Log: - #for lvl, msg in step.log_messages +{% for lvl, msg in step.log_messages %}\ [${lvl.upper().ljust(8)}] $msg - #end -#end -#end +{% end for %}\ +{% end for %}\ +{% end if %}\ -- Build URL: <$build.link> diff --git a/bitten/tests/notify.py b/bitten/tests/notify.py --- a/bitten/tests/notify.py +++ b/bitten/tests/notify.py @@ -83,6 +83,12 @@ self.assertTrue('author' in self.notifications_sent_to, 'Recipient list should contain the author') + def test_notification_body_render(self): + self.email.notify(self.build) + output = self.email.template.generate(**self.email.data).render('text') + self.assertTrue('Successful build of My Project [123]' in output) + self.assertTrue('' in output) + # TODO functional tests of generated mails