Code review comment for lp:~michael.nelson/launchpad/510331-syncsources-latest-pub

Revision history for this message
Michael Nelson (michael.nelson) wrote :

Hi gmb,

I just got back to this branch, tested it, and had errors or the webservice branch that tested syncSource(s) through the API. The error was simply because the sources used in the test weren't in the published status, but it was 500ing, rather than a nice API error, so I've updated the code to avoid that also.

Here's the diff:

=== modified file 'lib/lp/soyuz/model/archive.py'
--- lib/lp/soyuz/model/archive.py 2010-01-28 16:54:43 +0000
+++ lib/lp/soyuz/model/archive.py 2010-02-02 11:28:11 +0000
@@ -1127,10 +1127,11 @@
             getUtility(ISourcePackageNameSet)[name]
             # Grabbing the item at index 0 ensures it's the most recent
             # publication.
- sources.append(
- from_archive.getPublishedSources(
- name=name, exact_match=True,
- status=PackagePublishingStatus.PUBLISHED)[0])
+ published_sources = from_archive.getPublishedSources(
+ name=name, exact_match=True,
+ status=PackagePublishingStatus.PUBLISHED)
+ if published_sources.count() > 0:
+ sources.append(published_sources[0])
         return sources

     def _copySources(self, sources, to_pocket, to_series=None,

=== modified file 'lib/lp/soyuz/stories/webservice/xx-archive.txt'
--- lib/lp/soyuz/stories/webservice/xx-archive.txt 2009-10-07 08:28:03 +0000
+++ lib/lp/soyuz/stories/webservice/xx-archive.txt 2010-02-02 11:57:30 +0000
@@ -576,9 +576,12 @@
     ... sourcename="package1", version="1.0",
     ... archive=ubuntu_db.main_archive)

+ >>> from lp.soyuz.interfaces.publishing import (
+ ... PackagePublishingStatus)
     >>> ignore = test_publisher.getPubSource(
     ... sourcename="package1", version="1.1",
- ... archive=ubuntu_db.main_archive)
+ ... archive=ubuntu_db.main_archive,
+ ... status=PackagePublishingStatus.PUBLISHED)

     >>> ignore = test_publisher.getPubSource(
     ... sourcename="package2", version="1.0",
@@ -742,6 +745,8 @@

     >>> private_publication = test_publisher.createSource(
     ... cprov.archive, 'foocomm', '1.0-1')
+ >>> private_publication.secure_record.status = (
+ ... PackagePublishingStatus.PUBLISHED)

     >>> logout()

@@ -908,8 +913,10 @@
 version.

     >>> login('<email address hidden>')
- >>> unused = test_publisher.createSource(
+ >>> subsequent_version = test_publisher.createSource(
     ... cprov.archive, 'foocomm', '1.0-2')
+ >>> subsequent_version.secure_record.status = (
+ ... PackagePublishingStatus.PUBLISHED)
     >>> logout()

     >>> print cprov_webservice.named_post(

« Back to merge proposal