← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~abentley/launchpad/upload-failure-email-log into lp:launchpad/devel

 

Aaron Bentley has proposed merging lp:~abentley/launchpad/upload-failure-email-log into lp:launchpad/devel.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  #613958 upload failure emails should include the upload log
  https://bugs.launchpad.net/bugs/613958


= Summary =
This branch fixes bug bug #613958: upload failure emails should include the
upload log.

== Proposed fix ==
Include the upload log in the email

== Pre-implementation notes ==
None

== Implementation details ==
None

== Tests ==
bin/test -t test_generateEmail_upload_failure

== Demo and Q/A ==
Request a build with a debversion that has already been built.
The failure email should include the upload log.

= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/code/mail/sourcepackagerecipebuild.py
  lib/canonical/launchpad/emailtemplates/build-request.txt
  lib/lp/code/mail/tests/test_sourcepackagerecipebuild.py

./lib/lp/code/mail/sourcepackagerecipebuild.py
       5: E303 too many blank lines (3)
./lib/lp/code/mail/tests/test_sourcepackagerecipebuild.py
       5: E303 too many blank lines (3)
      30: W291 trailing whitespace
      39: W291 trailing whitespace
      40: W291 trailing whitespace
      41: W291 trailing whitespace
      42: W291 trailing whitespace
      45: E302 expected 2 blank lines, found 1
      30: Line has trailing whitespace.
      39: Line has trailing whitespace.
      40: Line has trailing whitespace.
      41: Line has trailing whitespace.
      42: Line has trailing whitespace.
-- 
https://code.launchpad.net/~abentley/launchpad/upload-failure-email-log/+merge/36205
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~abentley/launchpad/upload-failure-email-log into lp:launchpad/devel.
=== modified file 'lib/canonical/launchpad/emailtemplates/build-request.txt'
--- lib/canonical/launchpad/emailtemplates/build-request.txt	2010-07-30 16:24:59 +0000
+++ lib/canonical/launchpad/emailtemplates/build-request.txt	2010-09-21 20:08:05 +0000
@@ -4,4 +4,5 @@
  * Distroseries: %(distroseries)s
  * Duration: %(duration)s
  * Build Log: %(log_url)s
+ * Upload Log: %(upload_log_url)s
  * Builder: %(builder_url)s

=== modified file 'lib/lp/code/mail/sourcepackagerecipebuild.py'
--- lib/lp/code/mail/sourcepackagerecipebuild.py	2010-08-20 20:31:18 +0000
+++ lib/lp/code/mail/sourcepackagerecipebuild.py	2010-09-21 20:08:05 +0000
@@ -67,6 +67,7 @@
             'duration': '',
             'builder_url': '',
             'build_url': canonical_url(self.build),
+            'upload_log_url': '',
         })
         if self.build.builder is not None:
             params['builder_url'] = canonical_url(self.build.builder)
@@ -75,6 +76,8 @@
             params['duration'] = duration_formatter.approximateduration()
         if self.build.log is not None:
             params['log_url'] = self.build.log.getURL()
+        if self.build.upload_log is not None:
+            params['upload_log_url'] = self.build.upload_log_url
         return params
 
     def _getFooter(self, params):

=== modified file 'lib/lp/code/mail/tests/test_sourcepackagerecipebuild.py'
--- lib/lp/code/mail/tests/test_sourcepackagerecipebuild.py	2010-08-27 11:19:54 +0000
+++ lib/lp/code/mail/tests/test_sourcepackagerecipebuild.py	2010-09-21 20:08:05 +0000
@@ -27,6 +27,7 @@
  * Distroseries: distroseries
  * Duration: five minutes
  * Build Log: %s
+ * Upload Log: 
  * Builder: http://launchpad.dev/builders/bob
 """
 
@@ -37,6 +38,7 @@
  * Distroseries: distroseries
  * Duration: 
  * Build Log: 
+ * Upload Log: 
  * Builder: 
 """
 
@@ -44,6 +46,11 @@
 
     layer = LaunchpadFunctionalLayer
 
+    def makeStatusEmail(self, build):
+        mailer = SourcePackageRecipeBuildMailer.forStatus(build)
+        email = build.requester.preferredemail.email
+        return mailer.generateEmail(email, build.requester)
+
     def test_generateEmail(self):
         """GenerateEmail produces the right headers and body."""
         person = self.factory.makePerson(name='person')
@@ -59,9 +66,7 @@
         naked_build.builder = self.factory.makeBuilder(name='bob')
         naked_build.log = self.factory.makeLibraryFileAlias()
         Store.of(build).flush()
-        mailer = SourcePackageRecipeBuildMailer.forStatus(build)
-        email = build.requester.preferredemail.email
-        ctrl = mailer.generateEmail(email, build.requester)
+        ctrl = self.makeStatusEmail(build)
         self.assertEqual(
             u'[recipe build #%d] of ~person recipe in distroseries: '
             'Successfully built' % (build.id), ctrl.subject)
@@ -93,9 +98,7 @@
             recipe=cake, distroseries=secret, archive=pantry,
             status=BuildStatus.SUPERSEDED)
         Store.of(build).flush()
-        mailer = SourcePackageRecipeBuildMailer.forStatus(build)
-        email = build.requester.preferredemail.email
-        ctrl = mailer.generateEmail(email, build.requester)
+        ctrl = self.makeStatusEmail(build)
         self.assertEqual(
             u'[recipe build #%d] of ~person recipe in distroseries: '
             'Build for superseded Source' % (build.id), ctrl.subject)
@@ -114,6 +117,15 @@
         self.assertEqual(
             'SUPERSEDED', ctrl.headers['X-Launchpad-Build-State'])
 
+    def test_generateEmail_upload_failure(self):
+        """GenerateEmail works when many fields are NULL."""
+        build = self.factory.makeSourcePackageRecipeBuild()
+        removeSecurityProxy(build).upload_log = (
+            self.factory.makeLibraryFileAlias())
+        upload_log_fragment = 'Upload Log: %s' % build.upload_log_url
+        ctrl = self.makeStatusEmail(build)
+        self.assertTrue(upload_log_fragment in ctrl.body)
+
 
 def test_suite():
     return TestLoader().loadTestsFromName(__name__)