def test_estimation_for_the_whole_queue(self): QueueItemProcessedFactory(banner=self.banner, waiting_time_estimation=timedelta(minutes=5)) QueueItemFactory(banner=self.banner) QueueItemFactory(banner=self.banner) estimation = EstimateWaitingTime(banner=self.banner).call() self.assertEqual(estimation, timedelta(minutes=10))
def test_estimation_for_the_queue_item(self): QueueItemProcessedFactory(banner=self.banner, waiting_time_estimation=timedelta(minutes=5)) queue_item1 = QueueItemFactory(banner=self.banner) queue_item2 = QueueItemFactory(banner=self.banner) estimation = EstimateWaitingTime(banner=self.banner, queue_item=queue_item2).call() self.assertEqual(estimation, timedelta(minutes=5))
def time_estimation(self): return EstimateWaitingTime(banner=self.banner).call()
def test_no_processing_history(self): QueueItemFactory(banner=self.banner) estimation = EstimateWaitingTime(banner=self.banner).call() self.assertEqual(estimation, None)
def test_no_queue(self): QueueItemProcessedFactory(banner=self.banner) estimation = EstimateWaitingTime(banner=self.banner).call() self.assertEqual(estimation, timedelta(0))
def time_estimation(self): return EstimateWaitingTime(banner=self.banner, queue_item=self.queue_item).call()
def queue_entrypoint(request, banner_id): banner = get_object_or_404(Banner, pk=banner_id) time_estimation = EstimateWaitingTime(banner=banner).call() context = {'banner': banner, 'time_estimation': time_estimation} return render(request, 'banners/queue_entrypoint.html', context)