예제 #1
0
 def test_find_product(self):
     # Find all the jobs for a product regardless of date or job type.
     product = self.factory.makeProduct()
     metadata = {'foo': 'bar'}
     job_1 = FakeProductJob.create(product, metadata)
     job_2 = OtherFakeProductJob.create(product, metadata)
     FakeProductJob.create(self.factory.makeProduct(), metadata)
     jobs = list(ProductJobDerived.find(product=product))
     self.assertEqual(2, len(jobs))
     self.assertContentEqual([job_1.id, job_2.id], [job.id for job in jobs])
예제 #2
0
 def test_find_job_type(self):
     # Find all the jobs for a product and job_type regardless of date.
     product = self.factory.makeProduct()
     metadata = {'foo': 'bar'}
     job_1 = FakeProductJob.create(product, metadata)
     job_2 = FakeProductJob.create(product, metadata)
     OtherFakeProductJob.create(product, metadata)
     jobs = list(ProductJobDerived.find(
         product, job_type=ProductJobType.REVIEWER_NOTIFICATION))
     self.assertEqual(2, len(jobs))
     self.assertContentEqual([job_1.id, job_2.id], [job.id for job in jobs])
예제 #3
0
 def test_find_date_since(self):
     # Find all the jobs for a product since a date regardless of job_type.
     now = datetime.now(pytz.utc)
     seven_days_ago = now - timedelta(7)
     thirty_days_ago = now - timedelta(30)
     product = self.factory.makeProduct()
     metadata = {'foo': 'bar'}
     job_1 = FakeProductJob.create(product, metadata)
     removeSecurityProxy(job_1.job).date_created = thirty_days_ago
     job_2 = FakeProductJob.create(product, metadata)
     removeSecurityProxy(job_2.job).date_created = seven_days_ago
     job_3 = OtherFakeProductJob.create(product, metadata)
     removeSecurityProxy(job_3.job).date_created = now
     jobs = list(ProductJobDerived.find(product, date_since=seven_days_ago))
     self.assertEqual(2, len(jobs))
     self.assertContentEqual([job_2.id, job_3.id], [job.id for job in jobs])