Skip to content

Commit

Permalink
testresults: Add more details about the tested object
Browse files Browse the repository at this point in the history
People wanted to have the URL of the object tested directly in the
email. Add a few more details before the test summary.

Fixes: #132
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
  • Loading branch information
Damien Lespiau committed Feb 22, 2016
1 parent 6509c76 commit 7fcf43f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions patchwork/views/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,12 @@ def mbox(self, request, series_pk=None, pk=None):

class ResultMixin(object):

def _object_type(self, obj):
if isinstance(obj, SeriesRevision):
return "Series"
else:
return "Patch"

def _object_name(self, obj):
if isinstance(obj, SeriesRevision):
name = obj.series.name
Expand All @@ -299,7 +305,7 @@ def _object_name(self, obj):
return name
return obj.name

def _prepare_mail(self, result, obj):
def _prepare_mail(self, request, result, obj, check_obj):
if result.state == TestState.STATE_SUCCESS:
tick = u"✓"
else:
Expand All @@ -308,6 +314,12 @@ def _prepare_mail(self, result, obj):
result.get_state_display(),
self._object_name(obj))
body = ''
body += '== %s Details ==\n\n' % self._object_type(obj)
body += 'Series: ' + self._object_name(obj) + '\n'
body += 'URL : ' + \
request.build_absolute_uri(check_obj.get_absolute_url()) + '\n'
body += 'State : ' + result.get_state_display() + '\n'
body += '\n'
if result.summary:
body += "== Summary ==\n\n"
body += result.summary
Expand Down Expand Up @@ -378,7 +390,8 @@ def handle_test_results(self, request, obj, check_obj, q, ctx):
to = []

if to:
subject, body = self._prepare_mail(instance, obj)
subject, body = self._prepare_mail(request, instance,
obj, check_obj)
msgid = self._get_msgid(obj)
headers = {
'X-Patchwork-Hint': 'ignore',
Expand Down

0 comments on commit 7fcf43f

Please sign in to comment.