Merge lp:~jtv/launchpad/db-bug-788526 into lp:launchpad/db-devel

Proposed by Jeroen T. Vermeulen
Status: Merged
Approved by: Jeroen T. Vermeulen
Approved revision: no longer in the source branch.
Merged at revision: 10610
Proposed branch: lp:~jtv/launchpad/db-bug-788526
Merge into: lp:launchpad/db-devel
Diff against target: 455 lines (+233/-31)
6 files modified
lib/lp/registry/browser/distroseries.py (+52/-17)
lib/lp/registry/browser/tests/test_distroseries.py (+69/-0)
lib/lp/registry/templates/distroseries-localdifferences.pt (+6/-5)
lib/lp/soyuz/interfaces/distributionjob.py (+11/-0)
lib/lp/soyuz/model/distroseriesdifferencejob.py (+27/-1)
lib/lp/soyuz/tests/test_distroseriesdifferencejob.py (+68/-8)
To merge this branch: bzr merge lp:~jtv/launchpad/db-bug-788526
Reviewer Review Type Date Requested Status
Abel Deuring (community) code Approve
Review via email: mp+62623@code.launchpad.net

Commit message

[r=adeuring] Show updating as well as synchronizing DSDs in the UI.

Description of the change

= Summary =

When a DistroSeriesDifference on the DistroSeries:+localpackagediffs page is waiting for a sync to be completed, it is marked with "updating..."

We want that for pending DSD updates as well.

== Proposed fix ==

Very similar to what we already do for the package-copy jobs (the package syncs): add a "find jobs relevant to these DSDs" method to the job source. Call it once from a cachedproperty on the view, for the entire batch. Have a simple lookup method on the view to see whether a given DSD has jobs pending.

This was also a nice opportunity to decisions from TAL to the view class. I added a view method that computes the new string (and note that a DSD may be syncing and updating at the same time).

== Pre-implementation notes ==

Discussed with Julian. Note that a pending DSD update should not stop the user from requesting a sync for that DSD. In that respect this change differs from the one for pending syncs.

== Implementation details ==

I cleaned up some "if/elif/elif" code in cached_differences, replacing it with a dict. One of the items in the code was a bit irregular (a mono-tuple instead of an item, which in this case looks like it does the same thing) but I was too lazy to check whether that could be cleaned up as well. I left it in.

The set_derived_series_difference_jobs_feature_flag in lib/lp/registry/browser/tests/test_distroseries.py conforms to other similar functions right above it in the same module.

In lib/lp/soyuz/tests.test_distroseriesdifference.py I found a few test methods that were wrongly named so that they weren't run as tests. (Probably my fault; I've caught myself doing that a few times. I've made it a point to watch tests fail before I start making them succeed.) One needed a change to the test, but not one with any semantic implications. Otherwise, no surprises.

Something I kept running into is that DistroSeriesDifferenceJobs are not aware of multi-parent derived series yet. That change is going to affect this code in several places.

== Tests ==

{{{
./bin/test -vvc lp.registry.browser.tests.test_distroseries
./bin/test -vvc lp.soyuz.tests.test_distroseriesdifferencejob
}}}

== Demo and Q/A ==

Look at a DSDs page such as https://staging.launchpad.net/ubuntu/oneiric/+localpackagediffs

Requesting asynchronous package syncs for DSDs should cause them to be marked as "synchronizing..."

Updating a package and reloading +localpackagediffs should cause the corresponding DSD to be marked as "updating..."

The two messages may also combine.

= Launchpad lint =

I added no lint and I fixed some pre-existing lint, but left some in place as well:

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/registry/templates/distroseries-localdifferences.pt
  lib/lp/soyuz/model/distroseriesdifferencejob.py
  lib/lp/registry/browser/tests/test_distroseries.py
  lib/lp/soyuz/interfaces/distributionjob.py
  lib/lp/soyuz/tests/test_distroseriesdifferencejob.py
  lib/lp/registry/browser/distroseries.py

./lib/lp/soyuz/tests/test_distroseriesdifferencejob.py
     259: E261 at least two spaces before inline comment
     283: E261 at least two spaces before inline comment
     399: E261 at least two spaces before inline comment
     417: E261 at least two spaces before inline comment
     423: E261 at least two spaces before inline comment

To post a comment you must log in.
Revision history for this message
Abel Deuring (adeuring) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/registry/browser/distroseries.py'
--- lib/lp/registry/browser/distroseries.py 2011-05-24 10:08:33 +0000
+++ lib/lp/registry/browser/distroseries.py 2011-05-27 08:21:17 +0000
@@ -104,6 +104,9 @@
104from lp.services.worlddata.interfaces.language import ILanguageSet104from lp.services.worlddata.interfaces.language import ILanguageSet
105from lp.soyuz.browser.archive import PackageCopyingMixin105from lp.soyuz.browser.archive import PackageCopyingMixin
106from lp.soyuz.browser.packagesearch import PackageSearchViewBase106from lp.soyuz.browser.packagesearch import PackageSearchViewBase
107from lp.soyuz.interfaces.distributionjob import (
108 IDistroSeriesDifferenceJobSource,
109 )
107from lp.soyuz.interfaces.packagecopyjob import IPlainPackageCopyJobSource110from lp.soyuz.interfaces.packagecopyjob import IPlainPackageCopyJobSource
108from lp.soyuz.interfaces.queue import IPackageUploadSet111from lp.soyuz.interfaces.queue import IPackageUploadSet
109from lp.soyuz.model.packagecopyjob import specify_dsd_package112from lp.soyuz.model.packagecopyjob import specify_dsd_package
@@ -863,6 +866,21 @@
863 job_source = getUtility(IPlainPackageCopyJobSource)866 job_source = getUtility(IPlainPackageCopyJobSource)
864 return job_source.getPendingJobsPerPackage(self.context)867 return job_source.getPendingJobsPerPackage(self.context)
865868
869 @cachedproperty
870 def pending_dsd_updates(self):
871 """Pending `DistroSeriesDifference` update jobs.
872
873 :return: A `set` of `DistroSeriesDifference`s that have pending
874 `DistroSeriesDifferenceJob`s.
875 """
876 job_source = getUtility(IDistroSeriesDifferenceJobSource)
877 return job_source.getPendingJobsForDifferences(
878 self.context, self.cached_differences.batch)
879
880 def hasPendingDSDUpdate(self, dsd):
881 """Have there been changes that `dsd` is still being updated for?"""
882 return dsd in self.pending_dsd_updates
883
866 def hasPendingSync(self, dsd):884 def hasPendingSync(self, dsd):
867 """Is there a package-copying job pending to resolve `dsd`?"""885 """Is there a package-copying job pending to resolve `dsd`?"""
868 return self.pending_syncs.get(specify_dsd_package(dsd)) is not None886 return self.pending_syncs.get(specify_dsd_package(dsd)) is not None
@@ -898,6 +916,28 @@
898 return (916 return (
899 not self.isNewerThanParent(dsd) and not self.hasPendingSync(dsd))917 not self.isNewerThanParent(dsd) and not self.hasPendingSync(dsd))
900918
919 def describeJobs(self, dsd):
920 """Describe any jobs that may be pending for `dsd`.
921
922 Shows "synchronizing..." if the entry is being synchronized, and
923 "updating..." if the DSD is being updated with package changes.
924
925 :param dsd: A `DistroSeriesDifference` on the page.
926 :return: An HTML text describing work that is pending or in
927 progress for `dsd`; or None.
928 """
929 has_pending_dsd_update = self.hasPendingDSDUpdate(dsd)
930 has_pending_sync = self.hasPendingSync(dsd)
931 if not has_pending_dsd_update and not has_pending_sync:
932 return None
933
934 description = []
935 if has_pending_dsd_update:
936 description.append("updating")
937 if has_pending_sync:
938 description.append("synchronizing")
939 return " and ".join(description) + "…"
940
901 @property941 @property
902 def specified_name_filter(self):942 def specified_name_filter(self):
903 """If specified, return the name filter from the GET form data."""943 """If specified, return the name filter from the GET form data."""
@@ -924,23 +964,18 @@
924 @cachedproperty964 @cachedproperty
925 def cached_differences(self):965 def cached_differences(self):
926 """Return a batch navigator of filtered results."""966 """Return a batch navigator of filtered results."""
927 if self.specified_package_type == NON_IGNORED:967 package_type_dsd_status = {
928 status = (968 NON_IGNORED: (
929 DistroSeriesDifferenceStatus.NEEDS_ATTENTION,)969 DistroSeriesDifferenceStatus.NEEDS_ATTENTION,),
930 child_version_higher = False970 IGNORED: DistroSeriesDifferenceStatus.BLACKLISTED_CURRENT,
931 elif self.specified_package_type == IGNORED:971 HIGHER_VERSION_THAN_PARENT: (
932 status = (972 DistroSeriesDifferenceStatus.BLACKLISTED_CURRENT),
933 DistroSeriesDifferenceStatus.BLACKLISTED_CURRENT)973 RESOLVED: DistroSeriesDifferenceStatus.RESOLVED,
934 child_version_higher = False974 }
935 elif self.specified_package_type == HIGHER_VERSION_THAN_PARENT:975
936 status = (976 status = package_type_dsd_status[self.specified_package_type]
937 DistroSeriesDifferenceStatus.BLACKLISTED_CURRENT)977 child_version_higher = (
938 child_version_higher = True978 self.specified_package_type == HIGHER_VERSION_THAN_PARENT)
939 elif self.specified_package_type == RESOLVED:
940 status = DistroSeriesDifferenceStatus.RESOLVED
941 child_version_higher = False
942 else:
943 raise AssertionError('specified_package_type unknown')
944979
945 differences = getUtility(980 differences = getUtility(
946 IDistroSeriesDifferenceSource).getForDistroSeries(981 IDistroSeriesDifferenceSource).getForDistroSeries(
947982
=== modified file 'lib/lp/registry/browser/tests/test_distroseries.py'
--- lib/lp/registry/browser/tests/test_distroseries.py 2011-05-24 14:22:31 +0000
+++ lib/lp/registry/browser/tests/test_distroseries.py 2011-05-27 08:21:17 +0000
@@ -66,6 +66,7 @@
66 )66 )
67from lp.soyuz.interfaces.component import IComponentSet67from lp.soyuz.interfaces.component import IComponentSet
68from lp.soyuz.interfaces.distributionjob import (68from lp.soyuz.interfaces.distributionjob import (
69 IDistroSeriesDifferenceJobSource,
69 IInitialiseDistroSeriesJobSource,70 IInitialiseDistroSeriesJobSource,
70 )71 )
71from lp.soyuz.interfaces.packagecopyjob import IPlainPackageCopyJobSource72from lp.soyuz.interfaces.packagecopyjob import IPlainPackageCopyJobSource
@@ -73,6 +74,7 @@
73 ISourcePackageFormatSelectionSet,74 ISourcePackageFormatSelectionSet,
74 )75 )
75from lp.soyuz.model.archivepermission import ArchivePermission76from lp.soyuz.model.archivepermission import ArchivePermission
77from lp.soyuz.model import distroseriesdifferencejob
76from lp.soyuz.model.packagecopyjob import specify_dsd_package78from lp.soyuz.model.packagecopyjob import specify_dsd_package
77from lp.testing import (79from lp.testing import (
78 anonymous_logged_in,80 anonymous_logged_in,
@@ -85,6 +87,7 @@
85 TestCaseWithFactory,87 TestCaseWithFactory,
86 with_celebrity_logged_in,88 with_celebrity_logged_in,
87 )89 )
90from lp.testing.fakemethod import FakeMethod
88from lp.testing.matchers import HasQueryCount91from lp.testing.matchers import HasQueryCount
89from lp.testing.views import create_initialized_view92from lp.testing.views import create_initialized_view
9093
@@ -102,6 +105,12 @@
102 }))105 }))
103106
104107
108def set_derived_series_difference_jobs_feature_flag(test_case):
109 test_case.useFixture(FeatureFixture({
110 distroseriesdifferencejob.FEATURE_FLAG_ENABLE_MODULE: u'on',
111 }))
112
113
105class TestDistroSeriesView(TestCaseWithFactory):114class TestDistroSeriesView(TestCaseWithFactory):
106 """Test the distroseries +index view."""115 """Test the distroseries +index view."""
107116
@@ -1095,6 +1104,14 @@
10951104
1096 layer = LaunchpadFunctionalLayer1105 layer = LaunchpadFunctionalLayer
10971106
1107 def makeDSDJob(self, dsd):
1108 """Create a `DistroSeriesDifferenceJob` to update `dsd`."""
1109 job_source = getUtility(IDistroSeriesDifferenceJobSource)
1110 jobs = job_source.createForPackagePublication(
1111 dsd.derived_series, dsd.source_package_name,
1112 PackagePublishingPocket.RELEASE)
1113 return jobs[0]
1114
1098 def test_higher_radio_mentions_parent(self):1115 def test_higher_radio_mentions_parent(self):
1099 # The user is shown an option to display only the blacklisted1116 # The user is shown an option to display only the blacklisted
1100 # package with a higer version than in the parent.1117 # package with a higer version than in the parent.
@@ -1345,6 +1362,20 @@
13451362
1346 self.assertFalse(view.canPerformSync())1363 self.assertFalse(view.canPerformSync())
13471364
1365 def test_hasPendingDSDUpdate_returns_False_if_no_pending_update(self):
1366 dsd = self.factory.makeDistroSeriesDifference()
1367 view = create_initialized_view(
1368 dsd.derived_series, '+localpackagediffs')
1369 self.assertFalse(view.hasPendingDSDUpdate(dsd))
1370
1371 def test_hasPendingDSDUpdate_returns_True_if_pending_update(self):
1372 set_derived_series_difference_jobs_feature_flag(self)
1373 dsd = self.factory.makeDistroSeriesDifference()
1374 self.makeDSDJob(dsd)
1375 view = create_initialized_view(
1376 dsd.derived_series, '+localpackagediffs')
1377 self.assertTrue(view.hasPendingDSDUpdate(dsd))
1378
1348 def test_hasPendingSync_returns_False_if_no_pending_sync(self):1379 def test_hasPendingSync_returns_False_if_no_pending_sync(self):
1349 dsd = self.factory.makeDistroSeriesDifference()1380 dsd = self.factory.makeDistroSeriesDifference()
1350 view = create_initialized_view(1381 view = create_initialized_view(
@@ -1423,6 +1454,44 @@
1423 dsd.derived_series, '+localpackagediffs')1454 dsd.derived_series, '+localpackagediffs')
1424 self.assertTrue(view.canRequestSync(dsd))1455 self.assertTrue(view.canRequestSync(dsd))
14251456
1457 def test_canRequestSync_ignores_DSDJobs(self):
1458 dsd = self.factory.makeDistroSeriesDifference()
1459 view = create_initialized_view(
1460 dsd.derived_series, '+localpackagediffs')
1461 view.hasPendingDSDUpdate = FakeMethod(result=True)
1462 self.assertTrue(view.canRequestSync(dsd))
1463
1464 def test_describeJobs_returns_None_if_no_jobs(self):
1465 dsd = self.factory.makeDistroSeriesDifference()
1466 view = create_initialized_view(
1467 dsd.derived_series, '+localpackagediffs')
1468 self.assertIs(None, view.describeJobs(dsd))
1469
1470 def test_describeJobs_reports_pending_update(self):
1471 dsd = self.factory.makeDistroSeriesDifference()
1472 view = create_initialized_view(
1473 dsd.derived_series, '+localpackagediffs')
1474 view.hasPendingDSDUpdate = FakeMethod(result=True)
1475 view.hasPendingSync = FakeMethod(result=False)
1476 self.assertEqual("updating…", view.describeJobs(dsd))
1477
1478 def test_describeJobs_reports_pending_sync(self):
1479 dsd = self.factory.makeDistroSeriesDifference()
1480 view = create_initialized_view(
1481 dsd.derived_series, '+localpackagediffs')
1482 view.hasPendingDSDUpdate = FakeMethod(result=False)
1483 view.hasPendingSync = FakeMethod(result=True)
1484 self.assertEqual("synchronizing…", view.describeJobs(dsd))
1485
1486 def test_describeJobs_reports_pending_sync_and_update(self):
1487 dsd = self.factory.makeDistroSeriesDifference()
1488 view = create_initialized_view(
1489 dsd.derived_series, '+localpackagediffs')
1490 view.hasPendingDSDUpdate = FakeMethod(result=True)
1491 view.hasPendingSync = FakeMethod(result=True)
1492 self.assertEqual(
1493 "updating and synchronizing…", view.describeJobs(dsd))
1494
1426 def _syncAndGetView(self, derived_series, person, sync_differences,1495 def _syncAndGetView(self, derived_series, person, sync_differences,
1427 difference_type=None, view_name='+localpackagediffs'):1496 difference_type=None, view_name='+localpackagediffs'):
1428 # A helper to get the POST'ed sync view.1497 # A helper to get the POST'ed sync view.
14291498
=== modified file 'lib/lp/registry/templates/distroseries-localdifferences.pt'
--- lib/lp/registry/templates/distroseries-localdifferences.pt 2011-05-24 11:32:34 +0000
+++ lib/lp/registry/templates/distroseries-localdifferences.pt 2011-05-27 08:21:17 +0000
@@ -94,11 +94,12 @@
94 class="js-action toggle-extra"94 class="js-action toggle-extra"
95 tal:content="src_name">Foo</a>95 tal:content="src_name">Foo</a>
9696
97 <span97 <tal:activity
98 class="lowlight"98 define="activity python:view.describeJobs(difference)"
99 tal:condition="python: view.hasPendingSync(difference)">99 condition="activity">
100 &nbsp;&nbsp;synchronizing&hellip;100 &nbsp;&nbsp;
101 </span>101 <span class="lowlight" tal:content="structure activity"></span>
102 </tal:activity>
102 </td>103 </td>
103 <td tal:condition="python: not(view.has_unique_parent) and view.show_parent_version">104 <td tal:condition="python: not(view.has_unique_parent) and view.show_parent_version">
104 <a tal:attributes="href difference/parent_series/fmt:url"105 <a tal:attributes="href difference/parent_series/fmt:url"
105106
=== modified file 'lib/lp/soyuz/interfaces/distributionjob.py'
--- lib/lp/soyuz/interfaces/distributionjob.py 2011-05-13 10:00:02 +0000
+++ lib/lp/soyuz/interfaces/distributionjob.py 2011-05-27 08:21:17 +0000
@@ -104,6 +104,17 @@
104 :param pocket: The `PackagePublishingPocket` for the publication.104 :param pocket: The `PackagePublishingPocket` for the publication.
105 """105 """
106106
107 def getPendingJobsForDifferences(derived_series, distroseriesdifferences):
108 """Find `DistroSeriesDifferenceJob`s for `DistroSeriesDifference`s.
109
110 :param derived_series: The derived `DistroSeries` that the
111 differences (and jobs) must be for.
112 :param distroseriesdifferences:
113 An iterable of `DistroSeriesDifference`s.
114 :return: A dict mapping each of `distroseriesdifferences` that has
115 pending jobs to a list of its jobs.
116 """
117
107118
108class IDistroSeriesDifferenceJob(IRunnableJob):119class IDistroSeriesDifferenceJob(IRunnableJob):
109 """A Job that performs actions related to DSDs."""120 """A Job that performs actions related to DSDs."""
110121
=== modified file 'lib/lp/soyuz/model/distroseriesdifferencejob.py'
--- lib/lp/soyuz/model/distroseriesdifferencejob.py 2011-05-20 14:36:26 +0000
+++ lib/lp/soyuz/model/distroseriesdifferencejob.py 2011-05-27 08:21:17 +0000
@@ -14,7 +14,10 @@
14 implements,14 implements,
15 )15 )
1616
17from canonical.launchpad.interfaces.lpstorm import IMasterStore17from canonical.launchpad.interfaces.lpstorm import (
18 IMasterStore,
19 IStore,
20 )
18from lp.registry.interfaces.distroseriesdifference import (21from lp.registry.interfaces.distroseriesdifference import (
19 IDistroSeriesDifferenceSource,22 IDistroSeriesDifferenceSource,
20 )23 )
@@ -139,6 +142,29 @@
139 jobs.append(create_job(relative, sourcepackagename))142 jobs.append(create_job(relative, sourcepackagename))
140 return jobs143 return jobs
141144
145 @classmethod
146 def getPendingJobsForDifferences(cls, derived_series,
147 distroseriesdifferences):
148 """See `IDistroSeriesDifferenceJobSource`."""
149 jobs = IStore(DistributionJob).find(
150 DistributionJob,
151 DistributionJob.job_type == cls.class_job_type,
152 Job.id == DistributionJob.job_id,
153 Job._status.is_in(Job.PENDING_STATUSES),
154 DistributionJob.distroseries == derived_series)
155
156 # XXX JeroenVermeulen 2011-05-26 bug=758906: Check for parent
157 # series once it becomes available.
158 keyed_dsds = dict(
159 (dsd.source_package_name.id, dsd)
160 for dsd in distroseriesdifferences)
161 jobs_by_dsd = {}
162 for job in jobs:
163 dsd = keyed_dsds.get(job.metadata["sourcepackagename"])
164 if dsd is not None:
165 jobs_by_dsd.setdefault(dsd, []).append(cls(job))
166 return jobs_by_dsd
167
142 @property168 @property
143 def sourcepackagename(self):169 def sourcepackagename(self):
144 return SourcePackageName.get(self.metadata['sourcepackagename'])170 return SourcePackageName.get(self.metadata['sourcepackagename'])
145171
=== modified file 'lib/lp/soyuz/tests/test_distroseriesdifferencejob.py'
--- lib/lp/soyuz/tests/test_distroseriesdifferencejob.py 2011-05-23 10:54:01 +0000
+++ lib/lp/soyuz/tests/test_distroseriesdifferencejob.py 2011-05-27 08:21:17 +0000
@@ -9,6 +9,7 @@
9from psycopg2 import ProgrammingError9from psycopg2 import ProgrammingError
10from zope.component import getUtility10from zope.component import getUtility
11from zope.interface.verify import verifyObject11from zope.interface.verify import verifyObject
12from zope.security.proxy import removeSecurityProxy
1213
13from canonical.launchpad.interfaces.lpstorm import IMasterStore14from canonical.launchpad.interfaces.lpstorm import IMasterStore
14from canonical.launchpad.scripts.tests import run_script15from canonical.launchpad.scripts.tests import run_script
@@ -26,8 +27,10 @@
26from lp.services.job.interfaces.job import JobStatus27from lp.services.job.interfaces.job import JobStatus
27from lp.soyuz.enums import PackagePublishingStatus28from lp.soyuz.enums import PackagePublishingStatus
28from lp.soyuz.interfaces.distributionjob import (29from lp.soyuz.interfaces.distributionjob import (
30 DistributionJobType,
29 IDistroSeriesDifferenceJobSource,31 IDistroSeriesDifferenceJobSource,
30 )32 )
33from lp.soyuz.model.distributionjob import DistributionJob
31from lp.soyuz.model.distroseriesdifferencejob import (34from lp.soyuz.model.distroseriesdifferencejob import (
32 create_job,35 create_job,
33 DistroSeriesDifferenceJob,36 DistroSeriesDifferenceJob,
@@ -108,15 +111,17 @@
108 dsdjob = create_job(distroseries, package)111 dsdjob = create_job(distroseries, package)
109 self.assertEqual(JobStatus.WAITING, dsdjob.job.status)112 self.assertEqual(JobStatus.WAITING, dsdjob.job.status)
110113
111 def find_waiting_jobs_finds_waiting_jobs(self):114 def test_find_waiting_jobs_finds_waiting_jobs(self):
112 sourcepackage = self.factory.makeSourcePackage()115 sourcepackage = self.factory.makeSourcePackage()
113 distroseries, sourcepackagename = (116 distroseries, sourcepackagename = (
114 sourcepackage.distroseries, sourcepackage.distroseries)117 sourcepackage.distroseries, sourcepackage.distroseries)
115 job = create_job(distroseries, sourcepackagename)118 job = create_job(distroseries, sourcepackagename)
116 self.assertContentEqual(119 found_jobs = find_waiting_jobs(distroseries, sourcepackagename)
117 [job], find_waiting_jobs(distroseries, sourcepackagename))120 self.assertEqual([job], [
121 DistroSeriesDifferenceJob(found_job)
122 for found_job in found_jobs])
118123
119 def find_waiting_jobs_ignores_other_series(self):124 def test_find_waiting_jobs_ignores_other_series(self):
120 sourcepackage = self.factory.makeSourcePackage()125 sourcepackage = self.factory.makeSourcePackage()
121 distroseries, sourcepackagename = (126 distroseries, sourcepackagename = (
122 sourcepackage.distroseries, sourcepackage.distroseries)127 sourcepackage.distroseries, sourcepackage.distroseries)
@@ -125,7 +130,7 @@
125 self.assertContentEqual(130 self.assertContentEqual(
126 [], find_waiting_jobs(other_series, sourcepackagename))131 [], find_waiting_jobs(other_series, sourcepackagename))
127132
128 def find_waiting_jobs_ignores_other_packages(self):133 def test_find_waiting_jobs_ignores_other_packages(self):
129 sourcepackage = self.factory.makeSourcePackage()134 sourcepackage = self.factory.makeSourcePackage()
130 distroseries, sourcepackagename = (135 distroseries, sourcepackagename = (
131 sourcepackage.distroseries, sourcepackage.distroseries)136 sourcepackage.distroseries, sourcepackage.distroseries)
@@ -134,7 +139,7 @@
134 self.assertContentEqual(139 self.assertContentEqual(
135 [], find_waiting_jobs(distroseries, other_spn))140 [], find_waiting_jobs(distroseries, other_spn))
136141
137 def find_waiting_jobs_considers_only_waiting_jobs(self):142 def test_find_waiting_jobs_considers_only_waiting_jobs(self):
138 sourcepackage = self.factory.makeSourcePackage()143 sourcepackage = self.factory.makeSourcePackage()
139 distroseries, sourcepackagename = (144 distroseries, sourcepackagename = (
140 sourcepackage.distroseries, sourcepackage.distroseries)145 sourcepackage.distroseries, sourcepackage.distroseries)
@@ -192,6 +197,60 @@
192 distroseries, package, PackagePublishingPocket.PROPOSED)197 distroseries, package, PackagePublishingPocket.PROPOSED)
193 self.assertContentEqual([], find_waiting_jobs(distroseries, package))198 self.assertContentEqual([], find_waiting_jobs(distroseries, package))
194199
200 def test_getPendingJobsForDifferences_finds_job(self):
201 dsd = self.factory.makeDistroSeriesDifference()
202 job = create_job(dsd.derived_series, dsd.source_package_name)
203 self.assertEqual(
204 {dsd: [job]},
205 self.getJobSource().getPendingJobsForDifferences(
206 dsd.derived_series, [dsd]))
207
208 def test_getPendingJobsForDifferences_ignores_other_package(self):
209 dsd = self.factory.makeDistroSeriesDifference()
210 create_job(dsd.derived_series, self.factory.makeSourcePackageName())
211 self.assertEqual(
212 {},
213 self.getJobSource().getPendingJobsForDifferences(
214 dsd.derived_series, [dsd]))
215
216 def test_getPendingJobsForDifferences_ignores_other_derived_series(self):
217 dsd = self.factory.makeDistroSeriesDifference()
218 create_job(self.makeDerivedDistroSeries(), dsd.source_package_name)
219 self.assertEqual(
220 {},
221 self.getJobSource().getPendingJobsForDifferences(
222 dsd.derived_series, [dsd]))
223
224 def test_getPendingJobsForDifferences_ignores_other_parent_series(self):
225 # XXX JeroenVermeulen 2011-05-26 bug=758906: Can't test this
226 # until we can specify the right parent series when creating a
227 # job.
228 return
229
230 def test_getPendingJobsForDifferences_ignores_non_pending_jobs(self):
231 dsd = self.factory.makeDistroSeriesDifference()
232 job = create_job(dsd.derived_series, dsd.source_package_name)
233 removeSecurityProxy(job).job._status = JobStatus.COMPLETED
234 self.assertEqual(
235 {},
236 self.getJobSource().getPendingJobsForDifferences(
237 dsd.derived_series, [dsd]))
238
239 def test_getPendingJobsForDifferences_ignores_other_job_types(self):
240 # XXX JeroenVermeulen 2011-05-26 bug=758906: Once parent_series
241 # is incorporated into the job type, set it to dsd.parent_series
242 # on the fake job, or this test will become silently meaningless.
243 dsd = self.factory.makeDistroSeriesDifference()
244 DistributionJob(
245 distribution=dsd.derived_series.distribution,
246 distroseries=dsd.derived_series,
247 job_type=DistributionJobType.INITIALISE_SERIES,
248 metadata={"sourcepackagename": dsd.source_package_name.id})
249 self.assertEqual(
250 {},
251 self.getJobSource().getPendingJobsForDifferences(
252 dsd.derived_series, [dsd]))
253
195 def test_cronscript(self):254 def test_cronscript(self):
196 derived_series = self.makeDerivedDistroSeries()255 derived_series = self.makeDerivedDistroSeries()
197 package = self.factory.makeSourcePackageName()256 package = self.factory.makeSourcePackageName()
@@ -285,7 +344,7 @@
285 parent_packageset = self.factory.makePackageset(344 parent_packageset = self.factory.makePackageset(
286 distroseries=distro_series_parent.parent_series,345 distroseries=distro_series_parent.parent_series,
287 packages=packages)346 packages=packages)
288 derived_packageset = self.factory.makePackageset(347 self.factory.makePackageset(
289 distroseries=distro_series_parent.derived_series,348 distroseries=distro_series_parent.derived_series,
290 packages=packages, name=parent_packageset.name,349 packages=packages, name=parent_packageset.name,
291 owner=parent_packageset.owner, related_set=parent_packageset)350 owner=parent_packageset.owner, related_set=parent_packageset)
@@ -414,7 +473,8 @@
414 jobs = find_waiting_jobs(derived_series, source_package_name)473 jobs = find_waiting_jobs(derived_series, source_package_name)
415 self.runJob(jobs[0])474 self.runJob(jobs[0])
416 self.assertEqual(475 self.assertEqual(
417 DistroSeriesDifferenceStatus.BLACKLISTED_CURRENT, ds_diff[0].status)476 DistroSeriesDifferenceStatus.BLACKLISTED_CURRENT,
477 ds_diff[0].status)
418 self.assertEqual('1.0-1', ds_diff[0].base_version)478 self.assertEqual('1.0-1', ds_diff[0].base_version)
419479
420 def test_child_is_synced(self):480 def test_child_is_synced(self):

Subscribers

People subscribed via source and target branches

to status/vote changes: