Merge lp:~jelmer/launchpad/nascentuploadfile-tests into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Graham Binns on 2010-08-18 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 11400 |
| Proposed branch: | lp:~jelmer/launchpad/nascentuploadfile-tests |
| Merge into: | lp:launchpad |
| Diff against target: |
493 lines (+395/-13) 5 files modified
lib/lp/archiveuploader/changesfile.py (+11/-3) lib/lp/archiveuploader/dscfile.py (+1/-0) lib/lp/archiveuploader/nascentuploadfile.py (+6/-4) lib/lp/archiveuploader/tests/test_changesfile.py (+134/-6) lib/lp/archiveuploader/tests/test_nascentuploadfile.py (+243/-0) |
| To merge this branch: | bzr merge lp:~jelmer/launchpad/nascentuploadfile-tests |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Graham Binns (community) | code | 2010-08-17 | Approve on 2010-08-18 |
|
Review via email:
|
|||
Commit Message
Add more tests for ChangesFile, DebBinaryUpload
Description of the Change
This branch adds a bunch of tests and testinfrastructure for ChangesFile, DSCFile and two of the classes in nascentuploadfile. I'm adding these tests in preparation of adding some more fields (bug 613468).
While writing the tests I noticed that we seem to unconditionally require the "Changed-By" and "Date" files in the Changes file but don't reject uploads with these fields, so I've added them to the list of mandatory fields (bug filed & linked).
| Graham Binns (gmb) wrote : | # |
Hi Jelmer,
Thanks for those changes. Everything looks good, but you need to change the comments you've added to the start of the tests from the "Test that.." form to a straight statement of the expected behaviour.
So, instead of " # Test that unknown priorities automatically get changed to 'extra'," the comment should read " # Unknown priorities automatically get changed to 'extra'." This is a carry-over from doctest land, but being able to glance at a comment and know that foo should do bar rather than having to parse out the 'test that...' is nice. We know it's testing something because the method name starts with test_.
Other than that, this branch is good to land, so I'll mark it approved. No need to ping me about any subsequent changes unless they're not in-scope for this review.

Hi Jelmer,
Thanks for adding tests; always a good thing.
This is a good branch, but it suffers from a lot of issues w.r.t our
coding standards. All of the tests should have a leading comment
explaining the behaviour that they test. Also, the formatting of
callsites is inconsistent and should be changed to match our standards.
> === modified file 'lib/lp/ archiveuploader /changesfile. py' archiveuploader /changesfile. py 2010-08-01 06:59:04 +0000 archiveuploader /changesfile. py 2010-08-17 13:21:05 +0000 and_section) : and_section' matches a custom upload.
> --- lib/lp/
> +++ lib/lp/
> @@ -148,7 +152,7 @@
> def isCustom(self, component_
> """Check if given 'component_
>
> - We recognize an upload as custom if it is taget to a section like
> + We recognize an upload as custom if it is targetted at a section like
Targeted has only two 't's.
> 'raw-<something>'.
> Further checks will be performed in CustomUploadFile class.
> """
> @@ -215,6 +219,10 @@
> if len(self.files) == 0:
> yield UploadError("No files found in the changes")
>
> + if not 'urgency' in self._dict:
This should be expressed as:
if 'urgency' not in self._dict:
The current condition confused me.
> + # Urgency is recommended but not mandatory. Default to 'low' 'urgency' ] = "low" 'urgency' ].lower( ) archiveuploader /tests/ test_changesfil e.py' archiveuploader /tests/ test_changesfil e.py 2010-08-01 06:59:04 +0000 archiveuploader /tests/ test_changesfil e.py 2010-08-17 13:21:05 +0000 launchpad. scripts. logger import BufferLogger ssLayer der.changesfile import (CannotDetermin eFileTypeError, file_class_ and_name) file_class_ and_name)
> + self._dict[
> +
> raw_urgency = self._dict[
> if raw_urgency not in self.urgency_map:
> yield UploadWarning(
>
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -5,14 +5,20 @@
>
> __metaclass__ = type
>
> -from testtools import TestCase
> +from debian.deb822 import Changes
> +import os
> +
> +from canonical.
> +from canonical.testing import LaunchpadZopele
>
> from lp.archiveuploa
> - determine_
> + ChangesFile, determine_
Since you're here, you can tidy this up into the new one-line-per-import
format.
> from lp.archiveuploa der.dscfile import DSCFile der.nascentuplo adfile import ( File, DdebBinaryUploa dFile, SourceUploadFile, dFile) dFile, UploadError)
> from lp.archiveuploa
> DebBinaryUpload
> - UdebBinaryUploa
> + UdebBinaryUploa
Same here.
> +from lp.archiveuploa der.uploadpolic y import AbsolutelyAnyth ingGoesUploadPo licy leClassAndName( TestCase) : FileTypeError, file_class_ and_name, s(TestCase) : ssLayer leTests, self).setUp() ingGoesUploadPo licy() le(self, filename, cha...
> +from lp.testing import TestCase
>
>
> class TestDetermineFi
> @@ -52,3 +58,104 @@
> CannotDetermine
> determine_
> 'foo')
> +
> +
> +class ChangesFileTest
> + """Tests for ChangesFile."""
> +
> + layer = LaunchpadZopele
> +
> + def setUp(self):
> + super(ChangesFi
> + self.logger = BufferLogger()
> + self.policy = AbsolutelyAnyth
> +
> + def createChangesFi