Code review comment for lp:~al-maisan/launchpad/unembargo-443075

Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote :

Abel Deuring wrote:
> Review: Approve
> Hi Muharem,
>
> nice work, just a few cosmetic remarks, see below.

Hello Abel,

I am thanking you for the prompt review. All your suggestion were
accommodated except for one. Please see the enclosed incremental diff as
well as my replies below for more detail.

>
> Abel
>
>> === modified file 'lib/lp/soyuz/model/queue.py'
>> --- lib/lp/soyuz/model/queue.py 2009-10-01 07:05:22 +0000
>> +++ lib/lp/soyuz/model/queue.py 2009-10-09 09:50:27 +0000
>> @@ -367,15 +367,6 @@
>> assert self.sources.count() == 1, (
>> 'Source is mandatory for delayed copies.')
>> self.setAccepted()
>> - # The second assert guarantees that we'll actually have a SPR.
>> - spr = self.mySourcePackageRelease()
>> - # Use the changesfile of the original upload.
>> - changes_file_object = StringIO.StringIO(
>> - spr.package_upload.changesfile.read())
>> - self.notify(
>> - announce_list=self.distroseries.changeslist,
>> - changes_file_object=changes_file_object, allow_unsigned=True)
>> - self.syncUpdate()
>>
>> def rejectFromQueue(self, logger=None, dry_run=False):
>> """See `IPackageUpload`."""
>> @@ -496,6 +487,7 @@
>> else:
>> return None
>>
>> + @property
>> def mySourcePackageRelease(self):
>> """The source package release related to this queue item.
>
> As a Property, this should be named my_source_package_release

Fixed.

>
>
>> === modified file 'lib/lp/soyuz/tests/test_packageupload.py'
>> --- lib/lp/soyuz/tests/test_packageupload.py 2009-09-29 17:16:01 +0000
>> +++ lib/lp/soyuz/tests/test_packageupload.py 2009-10-09 09:50:27 +0000
>> @@ -198,6 +198,9 @@
>> self.assertEquals(
>> PackageUploadStatus.ACCEPTED, delayed_copy.status)
>>
>> + # Make sure no announcement email was sent at this point.
>> + self.assertEquals(len(stub.test_emails), 0)
>> +
>> self.layer.txn.commit()
>> self.layer.switchDbUser(self.dbuser)
>>
>> @@ -210,22 +213,26 @@
>>
>> # Check the announcement email.
>> from_addr, to_addrs, raw_msg = stub.test_emails.pop()
>> - # This is now a MIMEMultipart message.
>> msg = message_from_string(raw_msg)
>> body = msg.get_payload(0)
>> body = body.get_payload(decode=True)
>>
>> - self.assertEquals(from_addr, '<email address hidden>')
>> self.assertEquals(
>> - to_addrs, ['<email address hidden>'])
>> + str(to_addrs), "['<email address hidden>']")
>>
>> expected_subject = (
>> '[ubuntutest/breezy-autotest-security]\n\t'
>> 'dist-upgrader_20060302.0120_all.tar.gz, foocomm 1.0-2 (Accepted)')
>> self.assertEquals(msg['Subject'], expected_subject)
>>
>> - self.assertTrue(body.startswith('foocomm (1.0-2) breezy; urgency=low'))
>> -
>> + self.assertEquals(body,
>> + 'foocomm (1.0-2) breezy; urgency=low\n\n'
>> + ' * Initial version\n\n'
>> + 'Date: Thu, 16 Feb 2006 15:34:09 +0000\n'
>> + 'Changed-By: Foo Bar <email address hidden>\n'
>> + 'Maintainer: Launchpad team <email address hidden>\n'
>> + 'http://launchpad.dev/ubuntutest/breezy-autotest/+source/foocomm/1.0-2\n')
>
> This line is a bit too long. Could you split itto two lines? (OK,
> breaking the URL into two line does ot look nice either...

With your permission I'd like to leave it as it is.

>> +
>
> Please remove the whitespace in the line above.

Done.

>
>> self.layer.switchDbUser('launchpad')
>>
>> # One source and 2 binaries are pending publication. They all were
>>
>> === modified file 'lib/lp/soyuz/tests/test_publishing.py'
>> --- lib/lp/soyuz/tests/test_publishing.py 2009-09-10 08:56:15 +0000
>> +++ lib/lp/soyuz/tests/test_publishing.py 2009-10-09 09:50:27 +0000
>> @@ -385,6 +385,41 @@
>> return [BinaryPackagePublishingHistory.get(pub.id)
>> for pub in secure_pub_binaries]
>>
>> + def _findFile(self, top, name_fragment):
>
> A name like _findChangesFile would be a better, I think. The method
> does not find any file having name_fragment in its name ;)

Suggestion happily adopted :)

>
>> + """File with given name fragment in directory tree starting at top."""
>> + for root, dirs, files in os.walk(top, topdown=False):
>> + for name in files:
>> + if name.endswith('.changes') and name.find(name_fragment) > -1:
>> + return os.path.join(root, name)
>> + return None
>> +
>> + def createSource(
>> + self, archive, sourcename, version, distroseries=None,
>> + new_version=None):
>> + """Create source with meaningful '.changes' file."""
>> + top = 'lib/lp/archiveuploader/tests/data/suite'
>> + name_fragment = '%s_%s' % (sourcename, version)
>> + changesfile_path = self._findFile(top, name_fragment)
>> +
>
> Please remove the whitespace in the line above.

Done.

>
>> + source = None
>> +
>> + if changesfile_path is not None:
>> + if new_version is None:
>> + new_version = version
>> + changesfile_content = ''
>> + handle = open(changesfile_path, 'r')
>> + try:
>> + changesfile_content = handle.read()
>> + finally:
>> + handle.close()
>> +
>
> Please remove the whitespace in the line above.

Done.

>
>> + source = self.getPubSource(
>> + sourcename=sourcename, archive=archive, version=new_version,
>> + changes_file_content=changesfile_content,
>> + distroseries=distroseries)
>> +
>
> Please remove the whitespace in the line above.

Done.

>
>> + return source
>> +
>>
>> class TestNativePublishingBase(unittest.TestCase, SoyuzTestPublisher):
>> layer = LaunchpadZopelessLayer
>>
>>

Best regards

--
Muharem Hrnjadovic <email address hidden>
Public key id : B2BBFCFC
Key fingerprint : A5A3 CC67 2B87 D641 103F 5602 219F 6B60 B2BB FCFC

1=== modified file 'lib/lp/soyuz/model/queue.py'
2--- lib/lp/soyuz/model/queue.py 2009-10-09 09:43:12 +0000
3+++ lib/lp/soyuz/model/queue.py 2009-10-09 11:09:28 +0000
4@@ -488,7 +488,7 @@
5 return None
6
7 @property
8- def mySourcePackageRelease(self):
9+ def my_source_package_release(self):
10 """The source package release related to this queue item.
11
12 al-maisan, Wed, 30 Sep 2009 17:58:31 +0200:
13@@ -736,7 +736,7 @@
14 message.ORIGIN = '\nOrigin: %s' % changes['origin']
15
16 if self.sources or self.builds:
17- message.SPR_URL = canonical_url(self.mySourcePackageRelease)
18+ message.SPR_URL = canonical_url(self.my_source_package_release)
19
20 def _sendRejectionNotification(
21 self, recipients, changes_lines, changes, summary_text, dry_run,
22@@ -1133,7 +1133,7 @@
23 # the section of the source package uploaded in order to facilitate
24 # filtering on the part of the email recipients.
25 if self.sources:
26- spr = self.mySourcePackageRelease
27+ spr = self.my_source_package_release
28 xlp_component_header = 'component=%s, section=%s' % (
29 spr.component.name, spr.section.name)
30 extra_headers['X-Launchpad-Component'] = xlp_component_header
31
32=== modified file 'lib/lp/soyuz/tests/test_packageupload.py'
33--- lib/lp/soyuz/tests/test_packageupload.py 2009-10-07 08:28:03 +0000
34+++ lib/lp/soyuz/tests/test_packageupload.py 2009-10-09 11:12:08 +0000
35@@ -232,7 +232,7 @@
36 'Changed-By: Foo Bar <foo.bar@canonical.com>\n'
37 'Maintainer: Launchpad team <launchpad@lists.canonical.com>\n'
38 'http://launchpad.dev/ubuntutest/breezy-autotest/+source/foocomm/1.0-2\n')
39-
40+
41 self.layer.switchDbUser('launchpad')
42
43 # One source and 2 binaries are pending publication. They all were
44
45=== modified file 'lib/lp/soyuz/tests/test_publishing.py'
46--- lib/lp/soyuz/tests/test_publishing.py 2009-10-05 18:29:12 +0000
47+++ lib/lp/soyuz/tests/test_publishing.py 2009-10-09 11:12:47 +0000
48@@ -385,7 +385,7 @@
49 return [BinaryPackagePublishingHistory.get(pub.id)
50 for pub in secure_pub_binaries]
51
52- def _findFile(self, top, name_fragment):
53+ def _findChangesFile(self, top, name_fragment):
54 """File with given name fragment in directory tree starting at top."""
55 for root, dirs, files in os.walk(top, topdown=False):
56 for name in files:
57@@ -399,8 +399,8 @@
58 """Create source with meaningful '.changes' file."""
59 top = 'lib/lp/archiveuploader/tests/data/suite'
60 name_fragment = '%s_%s' % (sourcename, version)
61- changesfile_path = self._findFile(top, name_fragment)
62-
63+ changesfile_path = self._findChangesFile(top, name_fragment)
64+
65 source = None
66
67 if changesfile_path is not None:
68@@ -412,12 +412,12 @@
69 changesfile_content = handle.read()
70 finally:
71 handle.close()
72-
73+
74 source = self.getPubSource(
75 sourcename=sourcename, archive=archive, version=new_version,
76 changes_file_content=changesfile_content,
77 distroseries=distroseries)
78-
79+
80 return source
81
82

« Back to merge proposal