def test_report(self): tracker = Tracker() tracker.incr_labels('label1:cat1:dom1') tracker.incr_labels('label1:cat1:dom1') self.assertEqual(Statistic.objects.count(), 0) make_daily_report() self.assertEqual(tracker.flush_label('label1'), 0) self.assertEqual(Statistic.objects.count(), 1) stat = Statistic.objects.all()[0] self.assertEqual(stat.counter, 2) self.assertEqual(stat.category, 'cat1') self.assertEqual(stat.dom_id, 'dom1') tracker.incr_labels('label1:cat1:dom1') tracker.incr_labels('label1:cat1:dom1') stat = Statistic.objects.all()[0] self.assertEqual(stat.counter, 2) make_daily_report() stat = Statistic.objects.all()[0] self.assertEqual(stat.counter, 4) tracker.reset_cache()
def report(request): make_daily_report() return HttpResponse("ok")
def collect_statistic(): make_daily_report()