On Thu, Dec 10, 2009 at 10:50:36AM -0000, Julian Edwards wrote: > === modified file 'lib/lp/soyuz/tests/test_build.py' > --- lib/lp/soyuz/tests/test_build.py 2009-07-17 00:26:05 +0000 > +++ lib/lp/soyuz/tests/test_build.py 2009-12-10 10:50:36 +0000
> @@ -43,6 +47,69 @@ > > return depwait_build > > + def assertNoBuildQueue(self, build): > + """Test there's no buildqueue, buildpackagejob or job for `build`""" > + store = Store.of(build) > + result = store.find( > + BuildPackageJob, > + BuildPackageJob.build == build.id) > + bpj_count = result.count() > + self.assertEqual( > + bpj_count, 0, > + "Expected no buildpackagejob rows, got %s" % bpj_count) > + > + bpj = result.one() > + > + result = store.find( > + Job, > + bpj.job == Job.id) > + job_count = result.count() > + self.assertEqual( > + job_count, 0, > + "Expected no job rows, got %s" % job_count) > + > + job = result.one() > + > + result = store.find( > + BuildQueue, > + BuildQueue.job == job.id) > + buildqueue_count = result.count() > + self.assertEqual( > + buildqueue_count, 0, > + "Expected no buildqueue rows, got %s" % buildqueue_count) > + > + def testBuildqueueRemoval(self): > + """Test removing buildqueue items. > + > + Removing a Buildqueue row should also remove its associated > + BuildPackageJob and Job rows. > + """ > + # Create a build in depwait. > + depwait_build = self._setupSimpleDepwaitContext() > + > + # Grab the relevant db records for later comparison. > + store = Store.of(depwait_build) > + build_package_job = store.find( > + BuildPackageJob, depwait_build.id == BuildPackageJob.build).one() > + job = store.find(Job, Job.id == build_package_job.id).one() > + build_queue = store.find( > + BuildQueue, BuildQueue.job == job.id).one() > + > + depwait_build.buildqueue_record.destroySelf() > + > + # Test that the records above no longer exist in the db. > + self.assertEqual( > + store.find( > + BuildPackageJob, > + depwait_build.id == BuildPackageJob.build).count(), > + 0) > + self.assertEqual( > + store.find(Job, Job.id == build_package_job.id).count(), > + 0) > + self.assertEqual( > + store.find(BuildQueue, BuildQueue.job == job.id).count(), > + 0)
Can you be sure that the id attributes are the same, after the objects have been removed from the db? I'd be a bit wary of using objects that have been removed from the db. It could be that the attributes get set to None, for example, no?
-- Björn Tillenius | https://launchpad.net/~bjornt
« Back to merge proposal
On Thu, Dec 10, 2009 at 10:50:36AM -0000, Julian Edwards wrote: soyuz/tests/ test_build. py' soyuz/tests/ test_build. py 2009-07-17 00:26:05 +0000 soyuz/tests/ test_build. py 2009-12-10 10:50:36 +0000
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -43,6 +47,69 @@ eue(self, build): .build == build.id) emoval( self): leDepwaitContex t() depwait_ build) .build) .one() job.id) .one() build.buildqueu e_record. destroySelf( ) .build) .count( ), job.id) .count( ), BuildQueue, BuildQueue.job == job.id).count(),
>
> return depwait_build
>
> + def assertNoBuildQu
> + """Test there's no buildqueue, buildpackagejob or job for `build`"""
> + store = Store.of(build)
> + result = store.find(
> + BuildPackageJob,
> + BuildPackageJob
> + bpj_count = result.count()
> + self.assertEqual(
> + bpj_count, 0,
> + "Expected no buildpackagejob rows, got %s" % bpj_count)
> +
> + bpj = result.one()
> +
> + result = store.find(
> + Job,
> + bpj.job == Job.id)
> + job_count = result.count()
> + self.assertEqual(
> + job_count, 0,
> + "Expected no job rows, got %s" % job_count)
> +
> + job = result.one()
> +
> + result = store.find(
> + BuildQueue,
> + BuildQueue.job == job.id)
> + buildqueue_count = result.count()
> + self.assertEqual(
> + buildqueue_count, 0,
> + "Expected no buildqueue rows, got %s" % buildqueue_count)
> +
> + def testBuildqueueR
> + """Test removing buildqueue items.
> +
> + Removing a Buildqueue row should also remove its associated
> + BuildPackageJob and Job rows.
> + """
> + # Create a build in depwait.
> + depwait_build = self._setupSimp
> +
> + # Grab the relevant db records for later comparison.
> + store = Store.of(
> + build_package_job = store.find(
> + BuildPackageJob, depwait_build.id == BuildPackageJob
> + job = store.find(Job, Job.id == build_package_
> + build_queue = store.find(
> + BuildQueue, BuildQueue.job == job.id).one()
> +
> + depwait_
> +
> + # Test that the records above no longer exist in the db.
> + self.assertEqual(
> + store.find(
> + BuildPackageJob,
> + depwait_build.id == BuildPackageJob
> + 0)
> + self.assertEqual(
> + store.find(Job, Job.id == build_package_
> + 0)
> + self.assertEqual(
> + store.find(
> + 0)
Can you be sure that the id attributes are the same, after the objects
have been removed from the db? I'd be a bit wary of using objects that
have been removed from the db. It could be that the attributes get set
to None, for example, no?
-- /launchpad. net/~bjornt
Björn Tillenius | https:/