launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #27471
Re: [Merge] ~ilasc/launchpad:populate-store-upload-revision into launchpad:master
Diff comments:
> diff --git a/lib/lp/scripts/tests/test_garbo.py b/lib/lp/scripts/tests/test_garbo.py
> index 0d34fce..6e685b5 100644
> --- a/lib/lp/scripts/tests/test_garbo.py
> +++ b/lib/lp/scripts/tests/test_garbo.py
> @@ -1979,6 +1990,79 @@ class TestGarbo(FakeAdapterMixin, TestCaseWithFactory):
> self.assertEmailQueueLength(0)
>
>
> + def test_PopulateSnapBuildStoreRevision_triggered_correctly(self):
> + switch_dbuser('testadmin')
> + snap1 = self.factory.makeSnap()
> + self.factory.makeSnapBuild(
> + snap=snap1,
> + status=BuildStatus.FULLYBUILT)
> +
> + # This should trigger PopulateSnapBuildStoreRevision but doesn't
> + self.runDaily()
Not sure why this doesn't trigger the garbo job ?
> +
> + def test_PopulateSnapBuildStoreRevision(self):
> + switch_dbuser('testadmin')
> + snap1 = self.factory.makeSnap()
> + build1 = self.factory.makeSnapBuild(
> + snap=snap1,
> + status=BuildStatus.FULLYBUILT)
> +
> + # test that build1 does not get picked up
> + # as it is a build without a store upload
> + populator = PopulateSnapBuildStoreRevision(None)
> + rs = populator.findSnapBuilds()
> + self.assertEqual(0, rs.count())
> +
> + # Upload build and test it finds this one build that has no
> + # store_upload_revision set yet
> + job = getUtility(ISnapStoreUploadJobSource).create(build1)
> + client = FakeSnapStoreClient()
> + client.upload.result = (
> + "http://sca.example/dev/api/snaps/1/builds/1/status")
> + client.checkStatus.result = (
> + "http://sca.example/dev/click-apps/1/rev/1/", 1)
> + self.useFixture(ZopeUtilityFixture(client, ISnapStoreClient))
> + with dbuser(config.ISnapStoreUploadJobSource.dbuser):
> + run_isolated_jobs([job])
> +
> + populator = PopulateSnapBuildStoreRevision(None)
> + filter = populator.findSnapBuilds()
> + self.assertEqual(1, filter.count())
> + self.assertEqual(build1, filter.one())
> +
> + populator.__call__(5)
> + self.assertEqual(build1.store_upload_revision, 1)
> +
> + # Tests that of all builds for the same snap only those that have
> + # been uploaded to the store will get
> + # their new store_upload_revision DB field updated
> + build2 = self.factory.makeSnapBuild(
> + snap=snap1,
> + status=BuildStatus.FULLYBUILT)
> + build3 = self.factory.makeSnapBuild(
> + snap=snap1,
> + status=BuildStatus.FULLYBUILT)
> + job = getUtility(ISnapStoreUploadJobSource).create(build2)
> + client = FakeSnapStoreClient()
> + client.upload.result = (
> + "http://sca.example/dev/api/snaps/1/builds/2/status")
> + client.checkStatus.result = (
> + "http://sca.example/dev/click-apps/1/rev/1/", 1)
> + self.useFixture(ZopeUtilityFixture(client, ISnapStoreClient))
> + with dbuser(config.ISnapStoreUploadJobSource.dbuser):
> + run_isolated_jobs([job])
> +
> + populator = PopulateSnapBuildStoreRevision(None)
> +
> + filter = populator.findSnapBuilds()
> + self.assertEqual(1, filter.count())
> + self.assertEqual(build2, filter.one())
> +
> + populator.__call__(5)
> + self.assertEqual(build2.store_upload_revision, 1)
> + self.assertIsNone(build3.store_upload_revision)
> +
> +
> class TestGarboTasks(TestCaseWithFactory):
> layer = LaunchpadZopelessLayer
>
--
https://code.launchpad.net/~ilasc/launchpad/+git/launchpad/+merge/407679
Your team Launchpad code reviewers is requested to review the proposed merge of ~ilasc/launchpad:populate-store-upload-revision into launchpad:master.
References