Exemplo n.º 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()
Exemplo n.º 2
0
def track(request):
    labels = request.GET.get('labels', False)
    if not labels:
        return HttpResponse("syntax: ?labels=label1|label2")
    tracker = Tracker()
    tracker.incr_labels(str(labels))
    return HttpResponse("ok")
Exemplo n.º 3
0
def track(request):
    labels = request.GET.get('labels', False)
    if not labels:
        return HttpResponse("syntax: ?labels=label1|label2")
    tracker = Tracker()
    tracker.incr_labels(labels)
    return HttpResponse("ok")
Exemplo n.º 4
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()
Exemplo n.º 5
0
    def test_traker(self):

        tracker = Tracker()

        tracker.incr_labels('label1')
        self.assertEqual(tracker.labels, {'label1': {'lbl': 'label1'}})
        tracker.incr_labels('label1')
        self.assertEqual(tracker.flush_label('label1'), 2)
        self.assertEqual(tracker.flush_label('label1'), 0)
        tracker.save()

        tracker = Tracker()
        self.assertEqual(tracker.labels, {'label1': {'lbl': 'label1'}})
        tracker.reset_cache()
Exemplo n.º 6
0
    def test_traker(self):

        tracker = Tracker()

        tracker.incr_labels('label1')
        self.assertEqual(tracker.labels, {'label1': {'lbl': 'label1'}})
        tracker.incr_labels('label1')
        self.assertEqual(tracker.flush_label('label1'), 2)
        self.assertEqual(tracker.flush_label('label1'), 0)
        tracker.save()

        tracker = Tracker()
        self.assertEqual(tracker.labels, {'label1': {'lbl': 'label1'}})
        tracker.reset_cache()