Merge lp:~wgrant/launchpad/test-ddeb-matching into lp:launchpad/db-devel

Proposed by William Grant
Status: Merged
Approved by: Māris Fogels
Approved revision: no longer in the source branch.
Merged at revision: 9622
Proposed branch: lp:~wgrant/launchpad/test-ddeb-matching
Merge into: lp:launchpad/db-devel
Prerequisite: lp:~wgrant/launchpad/refactor-nuf-creation
Diff against target: 962 lines (+226/-114)
17 files modified
lib/canonical/launchpad/testing/fakepackager.py (+2/-1)
lib/lp/archiveuploader/nascentupload.py (+70/-52)
lib/lp/archiveuploader/tests/nascentupload-announcements.txt (+20/-19)
lib/lp/archiveuploader/tests/nascentupload-packageset.txt (+3/-3)
lib/lp/archiveuploader/tests/nascentupload-security-uploads.txt (+2/-2)
lib/lp/archiveuploader/tests/nascentupload.txt (+20/-19)
lib/lp/archiveuploader/tests/test_nascentupload.py (+85/-0)
lib/lp/archiveuploader/tests/test_nascentupload_documentation.py (+8/-3)
lib/lp/archiveuploader/uploadprocessor.py (+2/-1)
lib/lp/soyuz/browser/tests/distroseriesqueue-views.txt (+1/-1)
lib/lp/soyuz/doc/build-failedtoupload-workflow.txt (+1/-1)
lib/lp/soyuz/doc/distroseriesqueue-ddtp-tarball.txt (+3/-3)
lib/lp/soyuz/doc/distroseriesqueue-debian-installer.txt (+1/-1)
lib/lp/soyuz/doc/distroseriesqueue-dist-upgrader.txt (+4/-4)
lib/lp/soyuz/doc/distroseriesqueue-translations.txt (+1/-1)
lib/lp/soyuz/doc/distroseriesqueue.txt (+2/-2)
lib/lp/soyuz/scripts/tests/test_queue.py (+1/-1)
To merge this branch: bzr merge lp:~wgrant/launchpad/test-ddeb-matching
Reviewer Review Type Date Requested Status
Māris Fogels (community) code Approve
Review via email: mp+31482@code.launchpad.net

Commit message

Add unit tests for NascentUpload's DDEB matching code.

Description of the change

This branch factors out and adds unit tests for the DDEB-matching part of NascentUpload.

To make the tests less foul, I've altered NascentUpload to allow passing in an existing ChangesFile-like object, rather than requiring a path to a real file. This should eventually let us shrink existing tests throughout archiveuploader, and even remove test package data.

I've left the existing basic end-to-end test at the end of nascentupload-ddebs.txt, to ensure that detected errors do in fact cause rejection and not terrible explosions.

To post a comment you must log in.
Revision history for this message
Māris Fogels (mars) wrote :

Hi William,

This is a meaty change, lots of new code. Very nice. I especially like the refactoring of NascentUpload and _matchDDEBs(): both excellent changes.

Here is the list of notes I took while reviewing the code:

• Do ChangesFile objects have a .path attribute that you can use instead of string-sniffing in the constructor? If so, then perhaps you can push the fiddly conditional construction down into ChangesFile itself and at the same time eliminate the .changesfile_path attribute from the NascentUpload object. A NascentUpload.from_path() factory method would be even better, eliminating the conditional construction entirely.

• Switching from .reject() to 'yield UploadError()' is a pretty big API change, however I do not see any code in the diff (besides the tests) that is impacted by it. Why not?

• It would be good to have a docstring for _matchDDEBs() that tells you that it is a generator method.

• I think the test names could be improved a bit: the comment should be used as test method name, because the comments tell you what the desired behaviour is. They tell you what the test is actually testing.

• You might be able to rewrite all those "self.assertEquals([], list(self.upload._matchDDEBs()))" statements using the nifty testtools.TestCase.assertThat() method: self.assertThat(self.upload, matchesDDEBs([]))

With the above points taken into consideration, r=mars

review: Approve (code)
Revision history for this message
William Grant (wgrant) wrote :

> Hi William,
>
> This is a meaty change, lots of new code. Very nice. I especially like the
> refactoring of NascentUpload and _matchDDEBs(): both excellent changes.
>
> Here is the list of notes I took while reviewing the code:
>
> • Do ChangesFile objects have a .path attribute that you can use instead of
> string-sniffing in the constructor? If so, then perhaps you can push the
> fiddly conditional construction down into ChangesFile itself and at the same
> time eliminate the .changesfile_path attribute from the NascentUpload object.
> A NascentUpload.from_path() factory method would be even better, eliminating
> the conditional construction entirely.

Both fixed. All path-based NascentUpload() callsites updated to use NascentUpload.from_changesfile_path() instead.

> • Switching from .reject() to 'yield UploadError()' is a pretty big API
> change, however I do not see any code in the diff (besides the tests) that is
> impacted by it. Why not?

It's a pattern used throughout archiveuploader -- we call
run_and_collect_errors on an error generator, and it rejects with all the
yielded errors.

> • It would be good to have a docstring for _matchDDEBs() that tells you that
> it is a generator method.

Missed that. Fixed.

> • I think the test names could be improved a bit: the comment should be used
> as test method name, because the comments tell you what the desired behaviour
> is. They tell you what the test is actually testing.

Fair point. Fixed.

> • You might be able to rewrite all those "self.assertEquals([],
> list(self.upload._matchDDEBs()))" statements using the nifty
> testtools.TestCase.assertThat() method: self.assertThat(self.upload,
> matchesDDEBs([]))

I opted to instead create a tiny domain-specific assertion method.

> With the above points taken into consideration, r=mars

Thanks.

Revision history for this message
Māris Fogels (mars) wrote :

These changes still look good to me. I'll run it through ec2 land.

Maris

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/launchpad/testing/fakepackager.py'
--- lib/canonical/launchpad/testing/fakepackager.py 2009-09-14 04:07:18 +0000
+++ lib/canonical/launchpad/testing/fakepackager.py 2010-08-04 22:12:18 +0000
@@ -278,7 +278,8 @@
278 if suite is not None:278 if suite is not None:
279 policy.setDistroSeriesAndPocket(suite)279 policy.setDistroSeriesAndPocket(suite)
280280
281 upload = NascentUpload(changesfile_path, policy, logger)281 upload = NascentUpload.from_changesfile_path(
282 changesfile_path, policy, logger)
282 upload.process()283 upload.process()
283284
284 return upload285 return upload
285286
=== modified file 'lib/lp/archiveuploader/nascentupload.py'
--- lib/lp/archiveuploader/nascentupload.py 2010-08-03 08:49:19 +0000
+++ lib/lp/archiveuploader/nascentupload.py 2010-08-04 22:12:18 +0000
@@ -86,24 +86,35 @@
86 # Defined if we successfully do_accept() and storeObjectsInDatabase()86 # Defined if we successfully do_accept() and storeObjectsInDatabase()
87 queue_root = None87 queue_root = None
8888
89 def __init__(self, changesfile_path, policy, logger):89 def __init__(self, changesfile, policy, logger):
90 """Setup a ChangesFile based on given changesfile path.90 """Setup a NascentUpload for the given ChangesFile.
9191
92 May raise FatalUploadError due to unrecoverable problems building92 :param changesfile: the ChangesFile object to be uploaded.
93 the ChangesFile object.93 :param policy: the upload policy to be used.
94 Also store given and initialized Upload Policy, as 'policy'94 :param logger: the logger to be used.
95 """95 """
96 self.changesfile_path = changesfile_path
97 self.policy = policy96 self.policy = policy
98 self.logger = logger97 self.logger = logger
9998
100 self.rejections = []99 self.rejections = []
101 self.warnings = []100 self.warnings = []
102
103 self.librarian = getUtility(ILibraryFileAliasSet)101 self.librarian = getUtility(ILibraryFileAliasSet)
102
103 self.changes = changesfile
104
105 @classmethod
106 def from_changesfile_path(cls, changesfile_path, policy, logger):
107 """Create a NascentUpload from the given changesfile path.
108
109 May raise FatalUploadError due to unrecoverable problems building
110 the ChangesFile object.
111
112 :param changesfile_path: path to the changesfile to be uploaded.
113 :param policy: the upload policy to be used.
114 :param logger: the logger to be used.
115 """
104 try:116 try:
105 self.changes = ChangesFile(117 changesfile = ChangesFile(changesfile_path, policy, logger)
106 changesfile_path, self.policy, self.logger)
107 except UploadError, e:118 except UploadError, e:
108 # We can't run reject() because unfortunately we don't have119 # We can't run reject() because unfortunately we don't have
109 # the address of the uploader to notify -- we broke in that120 # the address of the uploader to notify -- we broke in that
@@ -112,6 +123,7 @@
112 # rejection to the archive admins. For now, this will end123 # rejection to the archive admins. For now, this will end
113 # up in the script log.124 # up in the script log.
114 raise FatalUploadError(str(e))125 raise FatalUploadError(str(e))
126 return cls(changesfile, policy, logger)
115127
116 def process(self):128 def process(self):
117 """Process this upload, checking it against policy, loading it into129 """Process this upload, checking it against policy, loading it into
@@ -148,6 +160,7 @@
148 self._check_sourceful_consistency()160 self._check_sourceful_consistency()
149 if self.binaryful:161 if self.binaryful:
150 self._check_binaryful_consistency()162 self._check_binaryful_consistency()
163 self.run_and_collect_errors(self._matchDDEBs)
151164
152 self.run_and_collect_errors(self.changes.verify)165 self.run_and_collect_errors(self.changes.verify)
153166
@@ -155,35 +168,6 @@
155 for uploaded_file in self.changes.files:168 for uploaded_file in self.changes.files:
156 self.run_and_collect_errors(uploaded_file.verify)169 self.run_and_collect_errors(uploaded_file.verify)
157170
158 unmatched_ddebs = {}
159 for uploaded_file in self.changes.files:
160 if isinstance(uploaded_file, DdebBinaryUploadFile):
161 ddeb_key = (uploaded_file.package, uploaded_file.version,
162 uploaded_file.architecture)
163 if ddeb_key in unmatched_ddebs:
164 self.reject("Duplicated debug packages: %s %s (%s)" %
165 ddeb_key)
166 else:
167 unmatched_ddebs[ddeb_key] = uploaded_file
168
169 for uploaded_file in self.changes.files:
170 # We need exactly a DEB, not a DDEB.
171 if (isinstance(uploaded_file, DebBinaryUploadFile) and
172 not isinstance(uploaded_file, DdebBinaryUploadFile)):
173 try:
174 matching_ddeb = unmatched_ddebs.pop(
175 (uploaded_file.package + '-dbgsym',
176 uploaded_file.version,
177 uploaded_file.architecture))
178 except KeyError:
179 continue
180 uploaded_file.ddeb_file = matching_ddeb
181 matching_ddeb.deb_file = uploaded_file
182
183 if len(unmatched_ddebs) > 0:
184 self.reject("Orphaned debug packages: %s" % ', '.join('%s %s (%s)' % d
185 for d in unmatched_ddebs))
186
187 if (len(self.changes.files) == 1 and171 if (len(self.changes.files) == 1 and
188 isinstance(self.changes.files[0], CustomUploadFile)):172 isinstance(self.changes.files[0], CustomUploadFile)):
189 self.logger.debug("Single Custom Upload detected.")173 self.logger.debug("Single Custom Upload detected.")
@@ -197,7 +181,7 @@
197 "Upload rejected because it contains binary packages.",181 "Upload rejected because it contains binary packages.",
198 "Ensure you are using `debuild -S`, or an equivalent",182 "Ensure you are using `debuild -S`, or an equivalent",
199 "command, to generate only the source package before",183 "command, to generate only the source package before",
200 "re-uploading."184 "re-uploading.",
201 ]185 ]
202 if self.is_ppa:186 if self.is_ppa:
203 messages.append(187 messages.append(
@@ -241,7 +225,7 @@
241 @property225 @property
242 def filename(self):226 def filename(self):
243 """Return the changesfile name."""227 """Return the changesfile name."""
244 return os.path.basename(self.changesfile_path)228 return os.path.basename(self.changesfile.filepath)
245229
246 @property230 @property
247 def is_new(self):231 def is_new(self):
@@ -254,7 +238,6 @@
254 #238 #
255 # Overall consistency checks239 # Overall consistency checks
256 #240 #
257
258 def _check_overall_consistency(self):241 def _check_overall_consistency(self):
259 """Heuristics checks on upload contents and declared architecture.242 """Heuristics checks on upload contents and declared architecture.
260243
@@ -329,7 +312,8 @@
329 """Heuristic checks on a sourceful upload.312 """Heuristic checks on a sourceful upload.
330313
331 Raises AssertionError when called for a non-sourceful upload.314 Raises AssertionError when called for a non-sourceful upload.
332 Ensures a sourceful upload has exactly one DSC.315 Ensures a sourceful upload has exactly one DSC. All further source
316 checks are performed later by the DSC.
333 """317 """
334 assert self.sourceful, (318 assert self.sourceful, (
335 "Source consistency check called for a non-source upload")319 "Source consistency check called for a non-source upload")
@@ -369,10 +353,49 @@
369 if len(considered_archs) > max:353 if len(considered_archs) > max:
370 self.reject("Upload has more architetures than it is supported.")354 self.reject("Upload has more architetures than it is supported.")
371355
356 def _matchDDEBs(self):
357 """Check and link DEBs and DDEBs in the upload.
358
359 Matches each DDEB to its corresponding DEB, adding links in both
360 directions. Unmatched or duplicated DDEBs result in upload errors.
361
362 This method is an error generator, i.e, it returns an iterator over
363 all exceptions that are generated while processing all mentioned
364 files.
365 """
366 unmatched_ddebs = {}
367 for uploaded_file in self.changes.files:
368 if isinstance(uploaded_file, DdebBinaryUploadFile):
369 ddeb_key = (uploaded_file.package, uploaded_file.version,
370 uploaded_file.architecture)
371 if ddeb_key in unmatched_ddebs:
372 yield UploadError(
373 "Duplicated debug packages: %s %s (%s)" % ddeb_key)
374 else:
375 unmatched_ddebs[ddeb_key] = uploaded_file
376
377 for uploaded_file in self.changes.files:
378 # We need exactly a DEB, not a DDEB.
379 if (isinstance(uploaded_file, DebBinaryUploadFile) and
380 not isinstance(uploaded_file, DdebBinaryUploadFile)):
381 try:
382 matching_ddeb = unmatched_ddebs.pop(
383 (uploaded_file.package + '-dbgsym',
384 uploaded_file.version,
385 uploaded_file.architecture))
386 except KeyError:
387 continue
388 uploaded_file.ddeb_file = matching_ddeb
389 matching_ddeb.deb_file = uploaded_file
390
391 if len(unmatched_ddebs) > 0:
392 yield UploadError(
393 "Orphaned debug packages: %s" % ', '.join(
394 '%s %s (%s)' % d for d in unmatched_ddebs))
395
372 #396 #
373 # Helpers for warnings and rejections397 # Helpers for warnings and rejections
374 #398 #
375
376 def run_and_check_error(self, callable):399 def run_and_check_error(self, callable):
377 """Run the given callable and process errors and warnings.400 """Run the given callable and process errors and warnings.
378401
@@ -471,7 +494,6 @@
471 #494 #
472 # Signature and ACL stuff495 # Signature and ACL stuff
473 #496 #
474
475 def verify_acl(self):497 def verify_acl(self):
476 """Check the signer's upload rights.498 """Check the signer's upload rights.
477499
@@ -501,7 +523,7 @@
501 ISourcePackageNameSet).queryByName(self.changes.dsc.package)523 ISourcePackageNameSet).queryByName(self.changes.dsc.package)
502524
503 rejection_reason = archive.checkUpload(525 rejection_reason = archive.checkUpload(
504 uploader, self.policy.distroseries, source_name, 526 uploader, self.policy.distroseries, source_name,
505 self.changes.dsc.component, self.policy.pocket, not self.is_new)527 self.changes.dsc.component, self.policy.pocket, not self.is_new)
506528
507 if rejection_reason is not None:529 if rejection_reason is not None:
@@ -510,7 +532,6 @@
510 #532 #
511 # Handling checking of versions and overrides533 # Handling checking of versions and overrides
512 #534 #
513
514 def getSourceAncestry(self, uploaded_file):535 def getSourceAncestry(self, uploaded_file):
515 """Return the last published source (ancestry) for a given file.536 """Return the last published source (ancestry) for a given file.
516537
@@ -739,8 +760,8 @@
739 return760 return
740761
741 component_override_map = {762 component_override_map = {
742 'contrib' : 'multiverse',763 'contrib': 'multiverse',
743 'non-free' : 'multiverse',764 'non-free': 'multiverse',
744 }765 }
745766
746 # Apply the component override and default to universe.767 # Apply the component override and default to universe.
@@ -814,7 +835,6 @@
814 #835 #
815 # Actually processing accepted or rejected uploads -- and mailing people836 # Actually processing accepted or rejected uploads -- and mailing people
816 #837 #
817
818 def do_accept(self, notify=True):838 def do_accept(self, notify=True):
819 """Accept the upload into the queue.839 """Accept the upload into the queue.
820840
@@ -921,7 +941,6 @@
921 #941 #
922 # Inserting stuff in the database942 # Inserting stuff in the database
923 #943 #
924
925 def storeObjectsInDatabase(self):944 def storeObjectsInDatabase(self):
926 """Insert this nascent upload into the database."""945 """Insert this nascent upload into the database."""
927946
@@ -1044,8 +1063,7 @@
1044 # See if there is an archive to override with.1063 # See if there is an archive to override with.
1045 distribution = self.policy.distroseries.distribution1064 distribution = self.policy.distroseries.distribution
1046 archive = distribution.getArchiveByComponent(1065 archive = distribution.getArchiveByComponent(
1047 PARTNER_COMPONENT_NAME1066 PARTNER_COMPONENT_NAME)
1048 )
10491067
1050 # Check for data problems:1068 # Check for data problems:
1051 if not archive:1069 if not archive:
10521070
=== modified file 'lib/lp/archiveuploader/tests/nascentupload-announcements.txt'
--- lib/lp/archiveuploader/tests/nascentupload-announcements.txt 2010-07-24 09:12:37 +0000
+++ lib/lp/archiveuploader/tests/nascentupload-announcements.txt 2010-08-04 22:12:18 +0000
@@ -79,7 +79,7 @@
79 >>> sync_policy = getPolicy(79 >>> sync_policy = getPolicy(
80 ... name='sync', distro='ubuntu', distroseries='hoary')80 ... name='sync', distro='ubuntu', distroseries='hoary')
8181
82 >>> bar_src = NascentUpload(82 >>> bar_src = NascentUpload.from_changesfile_path(
83 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),83 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),
84 ... sync_policy, mock_logger_quiet)84 ... sync_policy, mock_logger_quiet)
85 >>> bar_src.process()85 >>> bar_src.process()
@@ -132,7 +132,7 @@
132132
133Uploading the same package again will result in a rejection email:133Uploading the same package again will result in a rejection email:
134134
135 >>> bar_src = NascentUpload(135 >>> bar_src = NascentUpload.from_changesfile_path(
136 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),136 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),
137 ... sync_policy, mock_logger_quiet)137 ... sync_policy, mock_logger_quiet)
138 >>> bar_src.process()138 >>> bar_src.process()
@@ -270,7 +270,7 @@
270 >>> ppa_policy.archive = name16_ppa270 >>> ppa_policy.archive = name16_ppa
271 >>> ppa_policy.setDistroSeriesAndPocket('hoary')271 >>> ppa_policy.setDistroSeriesAndPocket('hoary')
272272
273 >>> ppa_bar_src = NascentUpload(273 >>> ppa_bar_src = NascentUpload.from_changesfile_path(
274 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),274 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),
275 ... ppa_policy, mock_logger_quiet)275 ... ppa_policy, mock_logger_quiet)
276 >>> ppa_bar_src.process()276 >>> ppa_bar_src.process()
@@ -308,7 +308,7 @@
308 ... name='sync', distro='ubuntu', distroseries='hoary')308 ... name='sync', distro='ubuntu', distroseries='hoary')
309 >>> modified_sync_policy.can_upload_binaries = True309 >>> modified_sync_policy.can_upload_binaries = True
310310
311 >>> bar_src = NascentUpload(311 >>> bar_src = NascentUpload.from_changesfile_path(
312 ... datadir('suite/bar_1.0-1_binary/bar_1.0-1_i386.changes'),312 ... datadir('suite/bar_1.0-1_binary/bar_1.0-1_i386.changes'),
313 ... modified_sync_policy, mock_logger_quiet)313 ... modified_sync_policy, mock_logger_quiet)
314 >>> bar_src.process()314 >>> bar_src.process()
@@ -336,7 +336,7 @@
336 >>> modified_sync_policy = getPolicy(336 >>> modified_sync_policy = getPolicy(
337 ... name='sync', distro='ubuntu', distroseries='hoary')337 ... name='sync', distro='ubuntu', distroseries='hoary')
338338
339 >>> lang_pack = NascentUpload(339 >>> lang_pack = NascentUpload.from_changesfile_path(
340 ... datadir('language-packs/language-pack-pt_1.0-1_source.changes'),340 ... datadir('language-packs/language-pack-pt_1.0-1_source.changes'),
341 ... modified_sync_policy, mock_logger_quiet)341 ... modified_sync_policy, mock_logger_quiet)
342 >>> lang_pack.process()342 >>> lang_pack.process()
@@ -367,7 +367,7 @@
367 >>> modified_sync_policy = getPolicy(367 >>> modified_sync_policy = getPolicy(
368 ... name='sync', distro='ubuntu', distroseries='hoary')368 ... name='sync', distro='ubuntu', distroseries='hoary')
369369
370 >>> lang_pack = NascentUpload(370 >>> lang_pack = NascentUpload.from_changesfile_path(
371 ... datadir('language-packs/language-pack-pt_1.0-2_source.changes'),371 ... datadir('language-packs/language-pack-pt_1.0-2_source.changes'),
372 ... modified_sync_policy, mock_logger_quiet)372 ... modified_sync_policy, mock_logger_quiet)
373 >>> lang_pack.process()373 >>> lang_pack.process()
@@ -398,7 +398,7 @@
398 ... name='insecure', distro='ubuntu', distroseries=None)398 ... name='insecure', distro='ubuntu', distroseries=None)
399 >>> insecure_policy.setDistroSeriesAndPocket('hoary-updates')399 >>> insecure_policy.setDistroSeriesAndPocket('hoary-updates')
400400
401 >>> lang_pack = NascentUpload(401 >>> lang_pack = NascentUpload.from_changesfile_path(
402 ... datadir('language-packs/language-pack-pt_1.0-3_source.changes'),402 ... datadir('language-packs/language-pack-pt_1.0-3_source.changes'),
403 ... insecure_policy, mock_logger_quiet)403 ... insecure_policy, mock_logger_quiet)
404 >>> lang_pack.process()404 >>> lang_pack.process()
@@ -423,7 +423,7 @@
423An UNAPPROVED binary upload via insecure will send one email saying that423An UNAPPROVED binary upload via insecure will send one email saying that
424the upload is waiting for approval:424the upload is waiting for approval:
425425
426 >>> bar_src = NascentUpload(426 >>> bar_src = NascentUpload.from_changesfile_path(
427 ... datadir('suite/bar_1.0-2/bar_1.0-2_source.changes'),427 ... datadir('suite/bar_1.0-2/bar_1.0-2_source.changes'),
428 ... insecure_policy, mock_logger_quiet)428 ... insecure_policy, mock_logger_quiet)
429 >>> bar_src.process()429 >>> bar_src.process()
@@ -451,7 +451,7 @@
451 >>> unapproved_backports_policy = getPolicy(451 >>> unapproved_backports_policy = getPolicy(
452 ... name='insecure', distro='ubuntu', distroseries=None)452 ... name='insecure', distro='ubuntu', distroseries=None)
453 >>> unapproved_backports_policy.setDistroSeriesAndPocket('hoary-backports')453 >>> unapproved_backports_policy.setDistroSeriesAndPocket('hoary-backports')
454 >>> bar_src = NascentUpload(454 >>> bar_src = NascentUpload.from_changesfile_path(
455 ... datadir('suite/bar_1.0-3_valid/bar_1.0-3_source.changes'),455 ... datadir('suite/bar_1.0-3_valid/bar_1.0-3_source.changes'),
456 ... unapproved_backports_policy, mock_logger_quiet)456 ... unapproved_backports_policy, mock_logger_quiet)
457 >>> bar_src.process()457 >>> bar_src.process()
@@ -479,7 +479,7 @@
479 ... name='sync', distro='ubuntu', distroseries=None)479 ... name='sync', distro='ubuntu', distroseries=None)
480 >>> modified_sync_policy.setDistroSeriesAndPocket('hoary-backports')480 >>> modified_sync_policy.setDistroSeriesAndPocket('hoary-backports')
481481
482 >>> bar_src = NascentUpload(482 >>> bar_src = NascentUpload.from_changesfile_path(
483 ... datadir('suite/bar_1.0-4/bar_1.0-4_source.changes'),483 ... datadir('suite/bar_1.0-4/bar_1.0-4_source.changes'),
484 ... modified_sync_policy, mock_logger_quiet)484 ... modified_sync_policy, mock_logger_quiet)
485 >>> bar_src.process()485 >>> bar_src.process()
@@ -536,7 +536,7 @@
536 ... name='security', distro='ubuntu', distroseries=None)536 ... name='security', distro='ubuntu', distroseries=None)
537 >>> security_policy.setDistroSeriesAndPocket('hoary-security')537 >>> security_policy.setDistroSeriesAndPocket('hoary-security')
538538
539 >>> bar_src = NascentUpload(539 >>> bar_src = NascentUpload.from_changesfile_path(
540 ... datadir('suite/bar_1.0-2/bar_1.0-2_source.changes'),540 ... datadir('suite/bar_1.0-2/bar_1.0-2_source.changes'),
541 ... security_policy, mock_logger_quiet)541 ... security_policy, mock_logger_quiet)
542 >>> bar_src.process()542 >>> bar_src.process()
@@ -729,7 +729,7 @@
729729
730 >>> hoary.status = SeriesStatus.DEVELOPMENT730 >>> hoary.status = SeriesStatus.DEVELOPMENT
731731
732 >>> bar_src = NascentUpload(732 >>> bar_src = NascentUpload.from_changesfile_path(
733 ... datadir(733 ... datadir(
734 ... 'suite/bar_1.0-5_debian_auto_sync/bar_1.0-5_source.changes'),734 ... 'suite/bar_1.0-5_debian_auto_sync/bar_1.0-5_source.changes'),
735 ... sync_policy, mock_logger_quiet)735 ... sync_policy, mock_logger_quiet)
@@ -749,7 +749,7 @@
749749
750In contrast, manual sync uploads do generate the announcement:750In contrast, manual sync uploads do generate the announcement:
751751
752 >>> bar_src = NascentUpload(752 >>> bar_src = NascentUpload.from_changesfile_path(
753 ... datadir(753 ... datadir(
754 ... 'suite/bar_1.0-6/bar_1.0-6_source.changes'),754 ... 'suite/bar_1.0-6/bar_1.0-6_source.changes'),
755 ... sync_policy, mock_logger_quiet)755 ... sync_policy, mock_logger_quiet)
@@ -789,7 +789,7 @@
789 ... name='security', distro='ubuntu', distroseries=None)789 ... name='security', distro='ubuntu', distroseries=None)
790 >>> security_policy.setDistroSeriesAndPocket('hoary-security')790 >>> security_policy.setDistroSeriesAndPocket('hoary-security')
791791
792 >>> bar_bin = NascentUpload(792 >>> bar_bin = NascentUpload.from_changesfile_path(
793 ... datadir('suite/bar_1.0-2_binary/bar_1.0-2_i386.changes'),793 ... datadir('suite/bar_1.0-2_binary/bar_1.0-2_i386.changes'),
794 ... security_policy, mock_logger_quiet)794 ... security_policy, mock_logger_quiet)
795 >>> bar_bin.process()795 >>> bar_bin.process()
@@ -849,7 +849,7 @@
849 >>> modified_sync_policy.can_upload_mixed = True849 >>> modified_sync_policy.can_upload_mixed = True
850 >>> modified_sync_policy.can_upload_binaries = True850 >>> modified_sync_policy.can_upload_binaries = True
851 >>> modified_sync_policy.can_upload_source = True851 >>> modified_sync_policy.can_upload_source = True
852 >>> foo_v1 = NascentUpload(852 >>> foo_v1 = NascentUpload.from_changesfile_path(
853 ... datadir('suite/foo_1.0-1_mixed/foo_1.0-1_i386.changes'),853 ... datadir('suite/foo_1.0-1_mixed/foo_1.0-1_i386.changes'),
854 ... modified_sync_policy, mock_logger_quiet)854 ... modified_sync_policy, mock_logger_quiet)
855 >>> foo_v1.process()855 >>> foo_v1.process()
@@ -867,7 +867,7 @@
867 >>> security_policy = getPolicy(867 >>> security_policy = getPolicy(
868 ... name='security', distro='ubuntu', distroseries=None)868 ... name='security', distro='ubuntu', distroseries=None)
869 >>> security_policy.setDistroSeriesAndPocket('hoary-security')869 >>> security_policy.setDistroSeriesAndPocket('hoary-security')
870 >>> foo_mixed = NascentUpload(870 >>> foo_mixed = NascentUpload.from_changesfile_path(
871 ... datadir('suite/foo_1.0-2.1/foo_1.0-2.1_source.changes'),871 ... datadir('suite/foo_1.0-2.1/foo_1.0-2.1_source.changes'),
872 ... security_policy, mock_logger_quiet)872 ... security_policy, mock_logger_quiet)
873 >>> foo_mixed.process()873 >>> foo_mixed.process()
@@ -905,7 +905,7 @@
905 >>> sync_policy = getPolicy(905 >>> sync_policy = getPolicy(
906 ... name='sync', distro='ubuntu', distroseries='hoary')906 ... name='sync', distro='ubuntu', distroseries='hoary')
907907
908 >>> bar_src = NascentUpload(908 >>> bar_src = NascentUpload.from_changesfile_path(
909 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),909 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),
910 ... sync_policy, mock_logger_quiet)910 ... sync_policy, mock_logger_quiet)
911 >>> bar_src.process()911 >>> bar_src.process()
@@ -975,7 +975,7 @@
975 >>> hoary.status = SeriesStatus.DEVELOPMENT975 >>> hoary.status = SeriesStatus.DEVELOPMENT
976 >>> anything_policy = getPolicy(976 >>> anything_policy = getPolicy(
977 ... name='anything', distro='ubuntu', distroseries='hoary')977 ... name='anything', distro='ubuntu', distroseries='hoary')
978 >>> bar_upload = NascentUpload(978 >>> bar_upload = NascentUpload.from_changesfile_path(
979 ... datadir(979 ... datadir(
980 ... 'suite/bar_1.0-10_utf8_changesfile/bar_1.0-10_source.changes'),980 ... 'suite/bar_1.0-10_utf8_changesfile/bar_1.0-10_source.changes'),
981 ... anything_policy, mock_logger_quiet)981 ... anything_policy, mock_logger_quiet)
@@ -1106,7 +1106,8 @@
11061106
1107And then try to upload using the changes file with the malformed name.1107And then try to upload using the changes file with the malformed name.
11081108
1109 >>> bar_src = NascentUpload(copyp, sync_policy, mock_logger_quiet)1109 >>> bar_src = NascentUpload.from_changesfile_path(
1110 ... copyp, sync_policy, mock_logger_quiet)
1110 >>> bar_src.process()1111 >>> bar_src.process()
1111 Traceback (most recent call last):1112 Traceback (most recent call last):
1112 ...1113 ...
11131114
=== modified file 'lib/lp/archiveuploader/tests/nascentupload-packageset.txt'
--- lib/lp/archiveuploader/tests/nascentupload-packageset.txt 2010-05-11 14:09:44 +0000
+++ lib/lp/archiveuploader/tests/nascentupload-packageset.txt 2010-08-04 22:12:18 +0000
@@ -31,7 +31,7 @@
31This time the upload will fail because the ACLs don't let31This time the upload will fail because the ACLs don't let
32"name16", the key owner, upload a package.32"name16", the key owner, upload a package.
3333
34 >>> bar_failed = NascentUpload(34 >>> bar_failed = NascentUpload.from_changesfile_path(
35 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),35 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),
36 ... insecure_policy, mock_logger_quiet)36 ... insecure_policy, mock_logger_quiet)
3737
@@ -111,7 +111,7 @@
111111
112Let's retry the upload.112Let's retry the upload.
113113
114 >>> bar_failed = NascentUpload(114 >>> bar_failed = NascentUpload.from_changesfile_path(
115 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),115 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),
116 ... insecure_policy, mock_logger_quiet)116 ... insecure_policy, mock_logger_quiet)
117117
@@ -166,7 +166,7 @@
166166
167 >>> commit()167 >>> commit()
168 >>> LaunchpadZopelessLayer.switchDbUser('uploader')168 >>> LaunchpadZopelessLayer.switchDbUser('uploader')
169 >>> bar2 = NascentUpload(169 >>> bar2 = NascentUpload.from_changesfile_path(
170 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),170 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),
171 ... insecure_policy, mock_logger_quiet)171 ... insecure_policy, mock_logger_quiet)
172 >>> bar2.process()172 >>> bar2.process()
173173
=== modified file 'lib/lp/archiveuploader/tests/nascentupload-security-uploads.txt'
--- lib/lp/archiveuploader/tests/nascentupload-security-uploads.txt 2010-07-24 09:12:37 +0000
+++ lib/lp/archiveuploader/tests/nascentupload-security-uploads.txt 2010-08-04 22:12:18 +0000
@@ -55,7 +55,7 @@
55The upload in question contains a source and its 2 builds for i386 and55The upload in question contains a source and its 2 builds for i386 and
56powerpc:56powerpc:
5757
58 >>> foo_mixed_upload = NascentUpload(58 >>> foo_mixed_upload = NascentUpload.from_changesfile_path(
59 ... datadir('suite/foo_1.0-1_multi_binary/foo_1.0-1_multi.changes'),59 ... datadir('suite/foo_1.0-1_multi_binary/foo_1.0-1_multi.changes'),
60 ... security_policy, mock_logger_quiet)60 ... security_policy, mock_logger_quiet)
61 >>> foo_mixed_upload.process()61 >>> foo_mixed_upload.process()
@@ -121,7 +121,7 @@
121security upload, for example, detecting that the source and the121security upload, for example, detecting that the source and the
122binaries sent do not match.122binaries sent do not match.
123123
124 >>> bar_mixed_upload = NascentUpload(124 >>> bar_mixed_upload = NascentUpload.from_changesfile_path(
125 ... datadir('suite/foo_1.0-1_broken_binary/bar_1.0-1_multi.changes'),125 ... datadir('suite/foo_1.0-1_broken_binary/bar_1.0-1_multi.changes'),
126 ... security_policy, mock_logger_quiet)126 ... security_policy, mock_logger_quiet)
127 >>> bar_mixed_upload.process()127 >>> bar_mixed_upload.process()
128128
=== modified file 'lib/lp/archiveuploader/tests/nascentupload.txt'
--- lib/lp/archiveuploader/tests/nascentupload.txt 2010-07-24 09:12:37 +0000
+++ lib/lp/archiveuploader/tests/nascentupload.txt 2010-08-04 22:12:18 +0000
@@ -45,14 +45,15 @@
45doc/nascentuploadfile.txt) object based on that. If anything goes45doc/nascentuploadfile.txt) object based on that. If anything goes
46wrong during this process FatalUploadError is raised:46wrong during this process FatalUploadError is raised:
4747
48 >>> NascentUpload(datadir("DOES-NOT-EXIST"), buildd_policy, mock_logger)48 >>> NascentUpload.from_changesfile_path(
49 ... datadir("DOES-NOT-EXIST"), buildd_policy, mock_logger)
49 Traceback (most recent call last):50 Traceback (most recent call last):
50 ...51 ...
51 FatalUploadError:...52 FatalUploadError:...
5253
53Otherwise a ChangesFile object is ready to use.54Otherwise a ChangesFile object is ready to use.
5455
55 >>> quodlibet = NascentUpload(56 >>> quodlibet = NascentUpload.from_changesfile_path(
56 ... datadir("quodlibet_0.13.1-1_i386.changes"),57 ... datadir("quodlibet_0.13.1-1_i386.changes"),
57 ... anything_policy, mock_logger_quiet)58 ... anything_policy, mock_logger_quiet)
5859
@@ -110,7 +111,7 @@
110is 'native' (only a TARBALL, no diff + orig) or 'has_orig' (uses ORIG111is 'native' (only a TARBALL, no diff + orig) or 'has_orig' (uses ORIG
111+ DIFF source form).112+ DIFF source form).
112113
113 >>> ed_source_upload = NascentUpload(114 >>> ed_source_upload = NascentUpload.from_changesfile_path(
114 ... datadir("ed_0.2-20_i386.changes.source-only-unsigned"),115 ... datadir("ed_0.2-20_i386.changes.source-only-unsigned"),
115 ... sync_policy, mock_logger_quiet)116 ... sync_policy, mock_logger_quiet)
116117
@@ -167,7 +168,7 @@
167168
168Let's try a simple binary upload:169Let's try a simple binary upload:
169170
170 >>> ed_binary_upload = NascentUpload(171 >>> ed_binary_upload = NascentUpload.from_changesfile_path(
171 ... datadir("ed_0.2-20_i386.changes.binary-only-unsigned"),172 ... datadir("ed_0.2-20_i386.changes.binary-only-unsigned"),
172 ... buildd_policy, mock_logger_quiet)173 ... buildd_policy, mock_logger_quiet)
173174
@@ -220,7 +221,7 @@
220 >>> modified_buildd_policy.can_upload_source = True221 >>> modified_buildd_policy.can_upload_source = True
221 >>> modified_buildd_policy.can_upload_mixed = True222 >>> modified_buildd_policy.can_upload_mixed = True
222223
223 >>> ed_mismatched_upload = NascentUpload(224 >>> ed_mismatched_upload = NascentUpload.from_changesfile_path(
224 ... datadir("ed_0.2-20_i386.changes.mismatched-arch-unsigned"),225 ... datadir("ed_0.2-20_i386.changes.mismatched-arch-unsigned"),
225 ... modified_buildd_policy, mock_logger_quiet)226 ... modified_buildd_policy, mock_logger_quiet)
226227
@@ -258,7 +259,7 @@
258 >>> modified_insecure_policy.can_upload_binaries = True259 >>> modified_insecure_policy.can_upload_binaries = True
259 >>> modified_insecure_policy.can_upload_mixed = True260 >>> modified_insecure_policy.can_upload_mixed = True
260261
261 >>> ed_mixed_upload = NascentUpload(262 >>> ed_mixed_upload = NascentUpload.from_changesfile_path(
262 ... datadir("ed_0.2-20_i386.changes"),263 ... datadir("ed_0.2-20_i386.changes"),
263 ... modified_insecure_policy, mock_logger_quiet)264 ... modified_insecure_policy, mock_logger_quiet)
264265
@@ -317,7 +318,7 @@
317318
318First up, construct an upload of just the ed source...319First up, construct an upload of just the ed source...
319320
320 >>> ed_src = NascentUpload(321 >>> ed_src = NascentUpload.from_changesfile_path(
321 ... datadir('split-upload-test/ed_0.2-20_source.changes'),322 ... datadir('split-upload-test/ed_0.2-20_source.changes'),
322 ... sync_policy, mock_logger_quiet)323 ... sync_policy, mock_logger_quiet)
323 >>> ed_src.process()324 >>> ed_src.process()
@@ -407,7 +408,7 @@
407maintainer's side), however it cannot store a proper408maintainer's side), however it cannot store a proper
408SourcePackageRelease.copyright content. See bug #134567.409SourcePackageRelease.copyright content. See bug #134567.
409410
410 >>> nocopyright_src = NascentUpload(411 >>> nocopyright_src = NascentUpload.from_changesfile_path(
411 ... datadir('suite/nocopyright_1.0-1/nocopyright_1.0-1_source.changes'),412 ... datadir('suite/nocopyright_1.0-1/nocopyright_1.0-1_source.changes'),
412 ... sync_policy, mock_logger_quiet)413 ... sync_policy, mock_logger_quiet)
413 >>> nocopyright_src.process()414 >>> nocopyright_src.process()
@@ -451,7 +452,7 @@
451published in the archive, which provides the same source package name452published in the archive, which provides the same source package name
452and source package version for the distroseries in question.453and source package version for the distroseries in question.
453454
454 >>> ed_src_dup = NascentUpload(455 >>> ed_src_dup = NascentUpload.from_changesfile_path(
455 ... datadir('split-upload-test/ed_0.2-20_source.changes'),456 ... datadir('split-upload-test/ed_0.2-20_source.changes'),
456 ... sync_policy, mock_logger_quiet)457 ... sync_policy, mock_logger_quiet)
457 >>> ed_src_dup.process()458 >>> ed_src_dup.process()
@@ -519,7 +520,7 @@
519 ... name='sync', distro='ubuntu', distroseries='hoary')520 ... name='sync', distro='ubuntu', distroseries='hoary')
520 >>> modified_sync_policy.can_upload_binaries = True521 >>> modified_sync_policy.can_upload_binaries = True
521522
522 >>> ed_bin = NascentUpload(523 >>> ed_bin = NascentUpload.from_changesfile_path(
523 ... datadir('split-upload-test/ed_0.2-20_i386.changes'),524 ... datadir('split-upload-test/ed_0.2-20_i386.changes'),
524 ... modified_sync_policy, mock_logger_quiet)525 ... modified_sync_policy, mock_logger_quiet)
525526
@@ -606,7 +607,7 @@
606607
607Upload new source 'multibar', step 1:608Upload new source 'multibar', step 1:
608609
609 >>> multibar_src_upload = NascentUpload(610 >>> multibar_src_upload = NascentUpload.from_changesfile_path(
610 ... datadir('suite/multibar_1.0-1/multibar_1.0-1_source.changes'),611 ... datadir('suite/multibar_1.0-1/multibar_1.0-1_source.changes'),
611 ... sync_policy, mock_logger_quiet)612 ... sync_policy, mock_logger_quiet)
612 >>> multibar_src_upload.process()613 >>> multibar_src_upload.process()
@@ -658,7 +659,7 @@
658 ... name='buildd', distro='ubuntu', distroseries='hoary',659 ... name='buildd', distro='ubuntu', distroseries='hoary',
659 ... buildid=multibar_build.id)660 ... buildid=multibar_build.id)
660661
661 >>> multibar_bin_upload = NascentUpload(662 >>> multibar_bin_upload = NascentUpload.from_changesfile_path(
662 ... datadir('suite/multibar_1.0-1/multibar_1.0-1_i386.changes'),663 ... datadir('suite/multibar_1.0-1/multibar_1.0-1_i386.changes'),
663 ... buildd_policy, mock_logger_quiet)664 ... buildd_policy, mock_logger_quiet)
664 >>> multibar_bin_upload.process()665 >>> multibar_bin_upload.process()
@@ -727,7 +728,7 @@
727 >>> norelease_sync_policy = getPolicy(728 >>> norelease_sync_policy = getPolicy(
728 ... name='sync', distro='ubuntu')729 ... name='sync', distro='ubuntu')
729730
730 >>> ed_src = NascentUpload(731 >>> ed_src = NascentUpload.from_changesfile_path(
731 ... datadir('updates-upload-test/ed_0.2-20_source.changes'),732 ... datadir('updates-upload-test/ed_0.2-20_source.changes'),
732 ... norelease_sync_policy, mock_logger_quiet)733 ... norelease_sync_policy, mock_logger_quiet)
733 >>> ed_src.process()734 >>> ed_src.process()
@@ -756,7 +757,7 @@
756Check the uploader behaviour against a missing orig.tar.gz file,757Check the uploader behaviour against a missing orig.tar.gz file,
757 bug # 30741.758 bug # 30741.
758759
759 >>> ed21_src = NascentUpload(760 >>> ed21_src = NascentUpload.from_changesfile_path(
760 ... datadir('ed-0.2-21/ed_0.2-21_source.changes'),761 ... datadir('ed-0.2-21/ed_0.2-21_source.changes'),
761 ... sync_policy, mock_logger_quiet)762 ... sync_policy, mock_logger_quiet)
762 >>> ed21_src.process()763 >>> ed21_src.process()
@@ -774,7 +775,7 @@
774'Standards-Version' field in DSC. See bug #75874 for further775'Standards-Version' field in DSC. See bug #75874 for further
775information.776information.
776777
777 >>> inst_src = NascentUpload(778 >>> inst_src = NascentUpload.from_changesfile_path(
778 ... datadir('test75874_0.1_source.changes'),779 ... datadir('test75874_0.1_source.changes'),
779 ... sync_policy, mock_logger_quiet)780 ... sync_policy, mock_logger_quiet)
780 >>> inst_src.process()781 >>> inst_src.process()
@@ -822,7 +823,7 @@
822When using 'insecure' policy, NascentUpload instace stores the DSC823When using 'insecure' policy, NascentUpload instace stores the DSC
823sigining key reference as an IGPGKey:824sigining key reference as an IGPGKey:
824825
825 >>> bar_ok = NascentUpload(826 >>> bar_ok = NascentUpload.from_changesfile_path(
826 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),827 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),
827 ... insecure_policy, mock_logger_quiet)828 ... insecure_policy, mock_logger_quiet)
828 >>> bar_ok.process()829 >>> bar_ok.process()
@@ -871,7 +872,7 @@
871This time the upload will fail because the ACLs don't let872This time the upload will fail because the ACLs don't let
872"name16", the key owner, upload a package.873"name16", the key owner, upload a package.
873874
874 >>> bar_failed = NascentUpload(875 >>> bar_failed = NascentUpload.from_changesfile_path(
875 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),876 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),
876 ... insecure_policy, mock_logger_quiet)877 ... insecure_policy, mock_logger_quiet)
877878
@@ -917,7 +918,7 @@
917918
918Now try the "bar" upload:919Now try the "bar" upload:
919920
920 >>> bar2 = NascentUpload(921 >>> bar2 = NascentUpload.from_changesfile_path(
921 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),922 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),
922 ... insecure_policy, mock_logger_quiet)923 ... insecure_policy, mock_logger_quiet)
923 >>> bar2.process()924 >>> bar2.process()
@@ -943,7 +944,7 @@
943Make this upload policy pertain to the copy archive.944Make this upload policy pertain to the copy archive.
944945
945 >>> copy_archive_policy.archive = copy_archive946 >>> copy_archive_policy.archive = copy_archive
946 >>> quodlibet = NascentUpload(947 >>> quodlibet = NascentUpload.from_changesfile_path(
947 ... datadir("quodlibet_0.13.1-1_i386.changes"),948 ... datadir("quodlibet_0.13.1-1_i386.changes"),
948 ... copy_archive_policy, mock_logger_quiet)949 ... copy_archive_policy, mock_logger_quiet)
949950
950951
=== added file 'lib/lp/archiveuploader/tests/test_nascentupload.py'
--- lib/lp/archiveuploader/tests/test_nascentupload.py 1970-01-01 00:00:00 +0000
+++ lib/lp/archiveuploader/tests/test_nascentupload.py 2010-08-04 22:12:18 +0000
@@ -0,0 +1,85 @@
1# Copyright 2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""Test NascentUpload functionality."""
5
6__metaclass__ = type
7
8from testtools import TestCase
9
10from canonical.testing import LaunchpadZopelessLayer
11from lp.archiveuploader.changesfile import determine_file_class_and_name
12from lp.archiveuploader.nascentupload import NascentUpload
13from lp.archiveuploader.tests import mock_logger
14
15
16class FakeChangesFile:
17
18 def __init__(self):
19 self.files = []
20
21
22class TestMatchDDEBs(TestCase):
23 """Tests that NascentUpload correctly links DEBs to their DDEBs.
24
25 Also verifies detection of DDEB-related error cases.
26 """
27
28 layer = LaunchpadZopelessLayer
29
30 def setUp(self):
31 super(TestMatchDDEBs, self).setUp()
32 self.changes = FakeChangesFile()
33 self.upload = NascentUpload(self.changes, None, mock_logger)
34
35 def addFile(self, filename):
36 """Add a file of the right type to the upload."""
37 package, cls = determine_file_class_and_name(filename)
38 file = cls(
39 filename, None, 100, 'devel', 'extra', package, '666',
40 self.changes, None, self.upload.logger)
41 self.changes.files.append(file)
42
43 def assertMatchDDEBErrors(self, error_list):
44 self.assertEquals(
45 error_list, [str(e) for e in self.upload._matchDDEBs()])
46
47 def testNoLinksWithNoBinaries(self):
48 # No links will be made if there are no binaries whatsoever.
49 self.addFile('something_1.0.diff.gz')
50 self.assertMatchDDEBErrors([])
51
52 def testNoLinksWithJustDEBs(self):
53 # No links will be made if there are no DDEBs.
54 self.addFile('blah_1.0_all.deb')
55 self.addFile('libblah_1.0_i386.deb')
56 self.assertMatchDDEBErrors([])
57 for file in self.changes.files:
58 self.assertIs(None, file.ddeb_file)
59
60 def testLinksMatchingDDEBs(self):
61 # DDEBs will be linked to their matching DEBs.
62 self.addFile('blah_1.0_all.deb')
63 self.addFile('libblah_1.0_i386.deb')
64 self.addFile('libblah-dbgsym_1.0_i386.ddeb')
65 self.assertMatchDDEBErrors([])
66 self.assertIs(None, self.changes.files[0].ddeb_file)
67 self.assertIs(self.changes.files[2], self.changes.files[1].ddeb_file)
68 self.assertIs(self.changes.files[1], self.changes.files[2].deb_file)
69 self.assertIs(None, self.changes.files[2].ddeb_file)
70
71 def testDuplicateDDEBsCauseErrors(self):
72 # An error will be raised if a DEB has more than one matching
73 # DDEB.
74 self.addFile('libblah_1.0_i386.deb')
75 self.addFile('libblah-dbgsym_1.0_i386.ddeb')
76 self.addFile('libblah-dbgsym_1.0_i386.ddeb')
77 self.assertMatchDDEBErrors(
78 ['Duplicated debug packages: libblah-dbgsym 666 (i386)'])
79
80 def testMismatchedDDEBsCauseErrors(self):
81 # An error will be raised if a DDEB has no matching DEB.
82 self.addFile('libblah_1.0_i386.deb')
83 self.addFile('libblah-dbgsym_1.0_amd64.ddeb')
84 self.assertMatchDDEBErrors(
85 ['Orphaned debug packages: libblah-dbgsym 666 (amd64)'])
086
=== modified file 'lib/lp/archiveuploader/tests/test_nascentupload_documentation.py'
--- lib/lp/archiveuploader/tests/test_nascentupload_documentation.py 2009-06-24 23:33:29 +0000
+++ lib/lp/archiveuploader/tests/test_nascentupload_documentation.py 2010-08-04 22:12:18 +0000
@@ -26,20 +26,25 @@
26def getUploadForSource(upload_path):26def getUploadForSource(upload_path):
27 """Return a NascentUpload object for a source."""27 """Return a NascentUpload object for a source."""
28 policy = getPolicy(name='sync', distro='ubuntu', distroseries='hoary')28 policy = getPolicy(name='sync', distro='ubuntu', distroseries='hoary')
29 return NascentUpload(datadir(upload_path), policy, mock_logger_quiet)29 return NascentUpload.from_changesfile_path(
30 datadir(upload_path), policy, mock_logger_quiet)
31
3032
31def getPPAUploadForSource(upload_path, ppa):33def getPPAUploadForSource(upload_path, ppa):
32 """Return a NascentUpload object for a PPA source."""34 """Return a NascentUpload object for a PPA source."""
33 policy = getPolicy(name='insecure', distro='ubuntu', distroseries='hoary')35 policy = getPolicy(name='insecure', distro='ubuntu', distroseries='hoary')
34 policy.archive = ppa36 policy.archive = ppa
35 return NascentUpload(datadir(upload_path), policy, mock_logger_quiet)37 return NascentUpload.from_changesfile_path(
38 datadir(upload_path), policy, mock_logger_quiet)
39
3640
37def getUploadForBinary(upload_path):41def getUploadForBinary(upload_path):
38 """Return a NascentUpload object for binaries."""42 """Return a NascentUpload object for binaries."""
39 policy = getPolicy(name='sync', distro='ubuntu', distroseries='hoary')43 policy = getPolicy(name='sync', distro='ubuntu', distroseries='hoary')
40 policy.can_upload_binaries = True44 policy.can_upload_binaries = True
41 policy.can_upload_mixed = True45 policy.can_upload_mixed = True
42 return NascentUpload(datadir(upload_path), policy, mock_logger_quiet)46 return NascentUpload.from_changesfile_path(
47 datadir(upload_path), policy, mock_logger_quiet)
4348
4449
45def testGlobalsSetup(test):50def testGlobalsSetup(test):
4651
=== modified file 'lib/lp/archiveuploader/uploadprocessor.py'
--- lib/lp/archiveuploader/uploadprocessor.py 2010-08-02 09:40:22 +0000
+++ lib/lp/archiveuploader/uploadprocessor.py 2010-08-04 22:12:18 +0000
@@ -335,7 +335,8 @@
335 # The path we want for NascentUpload is the path to the folder335 # The path we want for NascentUpload is the path to the folder
336 # containing the changes file (and the other files referenced by it).336 # containing the changes file (and the other files referenced by it).
337 changesfile_path = os.path.join(upload_path, changes_file)337 changesfile_path = os.path.join(upload_path, changes_file)
338 upload = NascentUpload(changesfile_path, policy, self.log)338 upload = NascentUpload.from_changesfile_path(
339 changesfile_path, policy, self.log)
339340
340 # Reject source upload to buildd upload paths.341 # Reject source upload to buildd upload paths.
341 first_path = relative_path.split(os.path.sep)[0]342 first_path = relative_path.split(os.path.sep)[0]
342343
=== modified file 'lib/lp/soyuz/browser/tests/distroseriesqueue-views.txt'
--- lib/lp/soyuz/browser/tests/distroseriesqueue-views.txt 2009-06-12 16:36:02 +0000
+++ lib/lp/soyuz/browser/tests/distroseriesqueue-views.txt 2010-08-04 22:12:18 +0000
@@ -260,7 +260,7 @@
260 ... distroseries='hoary')260 ... distroseries='hoary')
261 >>> sync_policy.can_upload_binaries = True261 >>> sync_policy.can_upload_binaries = True
262 >>> sync_policy.can_upload_mixed = True262 >>> sync_policy.can_upload_mixed = True
263 >>> foo_upload = NascentUpload(263 >>> foo_upload = NascentUpload.from_changesfile_path(
264 ... datadir('suite/foo_1.0-2_multi_binary/foo_1.0-2_i386.changes'),264 ... datadir('suite/foo_1.0-2_multi_binary/foo_1.0-2_i386.changes'),
265 ... sync_policy, mock_logger_quiet)265 ... sync_policy, mock_logger_quiet)
266 >>> foo_upload.process()266 >>> foo_upload.process()
267267
=== modified file 'lib/lp/soyuz/doc/build-failedtoupload-workflow.txt'
--- lib/lp/soyuz/doc/build-failedtoupload-workflow.txt 2010-05-12 08:17:20 +0000
+++ lib/lp/soyuz/doc/build-failedtoupload-workflow.txt 2010-08-04 22:12:18 +0000
@@ -165,7 +165,7 @@
165 ... distroseries=failedtoupload_candidate.distro_series.name,165 ... distroseries=failedtoupload_candidate.distro_series.name,
166 ... buildid=failedtoupload_candidate.id)166 ... buildid=failedtoupload_candidate.id)
167167
168 >>> cdrkit_bin_upload = NascentUpload(168 >>> cdrkit_bin_upload = NascentUpload.from_changesfile_path(
169 ... datadir('suite/cdrkit_1.0/cdrkit_1.0_i386.changes'),169 ... datadir('suite/cdrkit_1.0/cdrkit_1.0_i386.changes'),
170 ... buildd_policy, mock_logger_quiet)170 ... buildd_policy, mock_logger_quiet)
171 >>> cdrkit_bin_upload.process()171 >>> cdrkit_bin_upload.process()
172172
=== modified file 'lib/lp/soyuz/doc/distroseriesqueue-ddtp-tarball.txt'
--- lib/lp/soyuz/doc/distroseriesqueue-ddtp-tarball.txt 2009-05-13 14:05:27 +0000
+++ lib/lp/soyuz/doc/distroseriesqueue-ddtp-tarball.txt 2010-08-04 22:12:18 +0000
@@ -47,7 +47,7 @@
47 >>> sync_policy = getPolicy(47 >>> sync_policy = getPolicy(
48 ... name='sync', distro='ubuntutest', distroseries=None)48 ... name='sync', distro='ubuntutest', distroseries=None)
4949
50 >>> upload = NascentUpload(50 >>> upload = NascentUpload.from_changesfile_path(
51 ... datadir('ddtp-tarball/translations-main_20060728.changes'),51 ... datadir('ddtp-tarball/translations-main_20060728.changes'),
52 ... sync_policy, mock_logger_quiet)52 ... sync_policy, mock_logger_quiet)
53 >>> upload.process()53 >>> upload.process()
@@ -60,7 +60,7 @@
60 >>> insecure_policy = getPolicy(60 >>> insecure_policy = getPolicy(
61 ... name='insecure', distro='ubuntutest', distroseries=None)61 ... name='insecure', distro='ubuntutest', distroseries=None)
6262
63 >>> upload = NascentUpload(63 >>> upload = NascentUpload.from_changesfile_path(
64 ... datadir('ddtp-tarball/translations-main_20060728_all.changes'),64 ... datadir('ddtp-tarball/translations-main_20060728_all.changes'),
65 ... insecure_policy, mock_logger)65 ... insecure_policy, mock_logger)
66 DEBUG: Verifying signature on translations-main_20060728_all.changes66 DEBUG: Verifying signature on translations-main_20060728_all.changes
@@ -228,7 +228,7 @@
228 >>> insecure_policy = getPolicy(228 >>> insecure_policy = getPolicy(
229 ... name='insecure', distro='ubuntutest', distroseries=None)229 ... name='insecure', distro='ubuntutest', distroseries=None)
230230
231 >>> upload = NascentUpload(231 >>> upload = NascentUpload.from_changesfile_path(
232 ... datadir('ddtp-tarball/translations-main_20060817_all.changes'),232 ... datadir('ddtp-tarball/translations-main_20060817_all.changes'),
233 ... insecure_policy, mock_logger_quiet)233 ... insecure_policy, mock_logger_quiet)
234 >>> upload.process()234 >>> upload.process()
235235
=== modified file 'lib/lp/soyuz/doc/distroseriesqueue-debian-installer.txt'
--- lib/lp/soyuz/doc/distroseriesqueue-debian-installer.txt 2009-05-13 14:05:27 +0000
+++ lib/lp/soyuz/doc/distroseriesqueue-debian-installer.txt 2010-08-04 22:12:18 +0000
@@ -57,7 +57,7 @@
5757
58 >>> anything_policy.distroseries.changeslist = 'announce@example.com'58 >>> anything_policy.distroseries.changeslist = 'announce@example.com'
5959
60 >>> upload = NascentUpload(60 >>> upload = NascentUpload.from_changesfile_path(
61 ... datadir(61 ... datadir(
62 ... 'debian-installer/debian-installer_20070214ubuntu1_i386.changes'),62 ... 'debian-installer/debian-installer_20070214ubuntu1_i386.changes'),
63 ... anything_policy, mock_logger_quiet)63 ... anything_policy, mock_logger_quiet)
6464
=== modified file 'lib/lp/soyuz/doc/distroseriesqueue-dist-upgrader.txt'
--- lib/lp/soyuz/doc/distroseriesqueue-dist-upgrader.txt 2010-08-03 22:03:56 +0000
+++ lib/lp/soyuz/doc/distroseriesqueue-dist-upgrader.txt 2010-08-04 22:12:18 +0000
@@ -23,7 +23,7 @@
23 >>> sync_policy = getPolicy(23 >>> sync_policy = getPolicy(
24 ... name='sync', distro='ubuntutest', distroseries=None)24 ... name='sync', distro='ubuntutest', distroseries=None)
2525
26 >>> upload = NascentUpload(26 >>> upload = NascentUpload.from_changesfile_path(
27 ... datadir('dist-upgrader/dist-upgrader_20060302.0120.changes'),27 ... datadir('dist-upgrader/dist-upgrader_20060302.0120.changes'),
28 ... sync_policy, mock_logger)28 ... sync_policy, mock_logger)
29 DEBUG: Changes file can be unsigned.29 DEBUG: Changes file can be unsigned.
@@ -37,7 +37,7 @@
37 >>> insecure_policy = getPolicy(37 >>> insecure_policy = getPolicy(
38 ... name='insecure', distro='ubuntutest', distroseries=None)38 ... name='insecure', distro='ubuntutest', distroseries=None)
3939
40 >>> upload = NascentUpload(40 >>> upload = NascentUpload.from_changesfile_path(
41 ... datadir('dist-upgrader/dist-upgrader_20060302.0120_all.changes'),41 ... datadir('dist-upgrader/dist-upgrader_20060302.0120_all.changes'),
42 ... insecure_policy, mock_logger)42 ... insecure_policy, mock_logger)
43 DEBUG: Verifying signature on dist-upgrader_20060302.0120_all.changes43 DEBUG: Verifying signature on dist-upgrader_20060302.0120_all.changes
@@ -214,7 +214,7 @@
214 >>> insecure_policy = getPolicy(214 >>> insecure_policy = getPolicy(
215 ... name='insecure', distro='ubuntutest', distroseries=None)215 ... name='insecure', distro='ubuntutest', distroseries=None)
216216
217 >>> upload = NascentUpload(217 >>> upload = NascentUpload.from_changesfile_path(
218 ... datadir('dist-upgrader/dist-upgrader_20070219.1234_all.changes'),218 ... datadir('dist-upgrader/dist-upgrader_20070219.1234_all.changes'),
219 ... insecure_policy, mock_logger)219 ... insecure_policy, mock_logger)
220 DEBUG: Verifying signature on dist-upgrader_20070219.1234_all.changes220 DEBUG: Verifying signature on dist-upgrader_20070219.1234_all.changes
@@ -287,7 +287,7 @@
287287
288 >>> insecure_policy.archive = foobar_archive288 >>> insecure_policy.archive = foobar_archive
289289
290 >>> ppa_upload = NascentUpload(290 >>> ppa_upload = NascentUpload.from_changesfile_path(
291 ... datadir('dist-upgrader/dist-upgrader_20060302.0120_all.changes'),291 ... datadir('dist-upgrader/dist-upgrader_20060302.0120_all.changes'),
292 ... insecure_policy, mock_logger)292 ... insecure_policy, mock_logger)
293 DEBUG: Verifying signature on dist-upgrader_20060302.0120_all.changes293 DEBUG: Verifying signature on dist-upgrader_20060302.0120_all.changes
294294
=== modified file 'lib/lp/soyuz/doc/distroseriesqueue-translations.txt'
--- lib/lp/soyuz/doc/distroseriesqueue-translations.txt 2010-05-14 04:47:38 +0000
+++ lib/lp/soyuz/doc/distroseriesqueue-translations.txt 2010-08-04 22:12:18 +0000
@@ -77,7 +77,7 @@
77 ... name='buildd', distro='ubuntu', distroseries='dapper',77 ... name='buildd', distro='ubuntu', distroseries='dapper',
78 ... buildid=build.id)78 ... buildid=build.id)
7979
80 >>> pmount_upload = NascentUpload(80 >>> pmount_upload = NascentUpload.from_changesfile_path(
81 ... datadir('pmount_0.9.7-2ubuntu2_amd64.changes'),81 ... datadir('pmount_0.9.7-2ubuntu2_amd64.changes'),
82 ... buildd_policy, mock_logger)82 ... buildd_policy, mock_logger)
83 DEBUG: Changes file can be unsigned.83 DEBUG: Changes file can be unsigned.
8484
=== modified file 'lib/lp/soyuz/doc/distroseriesqueue.txt'
--- lib/lp/soyuz/doc/distroseriesqueue.txt 2010-05-14 04:51:42 +0000
+++ lib/lp/soyuz/doc/distroseriesqueue.txt 2010-08-04 22:12:18 +0000
@@ -69,7 +69,7 @@
69 >>> anything_policy.can_upload_binaries = True69 >>> anything_policy.can_upload_binaries = True
70 >>> anything_policy.can_upload_mixed = True70 >>> anything_policy.can_upload_mixed = True
7171
72 >>> ed_upload = NascentUpload(72 >>> ed_upload = NascentUpload.from_changesfile_path(
73 ... datadir('ed_0.2-20_i386.changes'),73 ... datadir('ed_0.2-20_i386.changes'),
74 ... anything_policy, mock_logger_quiet)74 ... anything_policy, mock_logger_quiet)
7575
@@ -263,7 +263,7 @@
263 >>> insecure_policy = getPolicy(263 >>> insecure_policy = getPolicy(
264 ... name='insecure', distro='ubuntu', distroseries='hoary')264 ... name='insecure', distro='ubuntu', distroseries='hoary')
265265
266 >>> bar_ok = NascentUpload(266 >>> bar_ok = NascentUpload.from_changesfile_path(
267 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),267 ... datadir('suite/bar_1.0-1/bar_1.0-1_source.changes'),
268 ... insecure_policy, mock_logger_quiet)268 ... insecure_policy, mock_logger_quiet)
269 >>> bar_ok.process()269 >>> bar_ok.process()
270270
=== modified file 'lib/lp/soyuz/scripts/tests/test_queue.py'
--- lib/lp/soyuz/scripts/tests/test_queue.py 2010-02-09 00:17:40 +0000
+++ lib/lp/soyuz/scripts/tests/test_queue.py 2010-08-04 22:12:18 +0000
@@ -123,7 +123,7 @@
123 LaunchpadZopelessLayer.switchDbUser("uploader")123 LaunchpadZopelessLayer.switchDbUser("uploader")
124 sync_policy = getPolicy(124 sync_policy = getPolicy(
125 name='sync', distro='ubuntu', distroseries='breezy-autotest')125 name='sync', distro='ubuntu', distroseries='breezy-autotest')
126 bar_src = NascentUpload(126 bar_src = NascentUpload.from_changesfile_path(
127 datadir(changesfile),127 datadir(changesfile),
128 sync_policy, mock_logger_quiet)128 sync_policy, mock_logger_quiet)
129 bar_src.process()129 bar_src.process()

Subscribers

People subscribed via source and target branches

to status/vote changes: