Example #1
0
    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()
Example #2
0
    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()
Example #3
0
def report(request):
    make_daily_report()
    return HttpResponse("ok")
Example #4
0
def collect_statistic():
    make_daily_report()
Example #5
0
def report(request):
    make_daily_report()
    return HttpResponse("ok")
Example #6
0
def collect_statistic():
    make_daily_report()