2016-09-30 06:26:27 +02:00
|
|
|
from lbrynet import analytics
|
|
|
|
|
|
|
|
from twisted.trial import unittest
|
|
|
|
|
|
|
|
|
|
|
|
class TrackTest(unittest.TestCase):
|
2016-10-11 22:12:10 +02:00
|
|
|
def test_empty_summarize_is_None(self):
|
2016-09-30 06:26:27 +02:00
|
|
|
track = analytics.Track()
|
2016-10-18 23:49:31 +02:00
|
|
|
_, result = track.summarize_and_reset('a')
|
2016-10-11 22:12:10 +02:00
|
|
|
self.assertEqual(None, result)
|
2016-09-30 06:26:27 +02:00
|
|
|
|
|
|
|
def test_can_get_sum_of_metric(self):
|
|
|
|
track = analytics.Track()
|
|
|
|
track.add_observation('b', 1)
|
|
|
|
track.add_observation('b', 2)
|
|
|
|
|
2016-10-18 23:49:31 +02:00
|
|
|
_, result = track.summarize_and_reset('b')
|
2016-09-30 06:26:27 +02:00
|
|
|
self.assertEqual(3, result)
|
|
|
|
|
|
|
|
def test_summarize_resets_metric(self):
|
|
|
|
track = analytics.Track()
|
|
|
|
track.add_observation('metric', 1)
|
|
|
|
track.add_observation('metric', 2)
|
|
|
|
|
2016-10-18 23:49:31 +02:00
|
|
|
track.summarize_and_reset('metric')
|
|
|
|
_, result = track.summarize_and_reset('metric')
|
2016-10-11 22:12:10 +02:00
|
|
|
self.assertEqual(None, result)
|