lbry-sdk/tests/unit/analytics/test_track.py

28 lines
881 B
Python
Raw Normal View History

2016-09-30 06:26:27 +02:00
from lbrynet import analytics
from twisted.trial import unittest
class TrackTest(unittest.TestCase):
2017-04-26 20:15:38 +02:00
def test_empty_summarize_is_none(self):
track = analytics.Manager(None, 'x', 'y', 'z')
_, 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):
2017-04-26 20:15:38 +02:00
track = analytics.Manager(None, 'x', 'y', 'z')
2016-09-30 06:26:27 +02:00
track.add_observation('b', 1)
track.add_observation('b', 2)
_, result = track.summarize_and_reset('b')
2016-09-30 06:26:27 +02:00
self.assertEqual(3, result)
def test_summarize_resets_metric(self):
2017-04-26 20:15:38 +02:00
track = analytics.Manager(None, 'x', 'y', 'z')
2016-09-30 06:26:27 +02:00
track.add_observation('metric', 1)
track.add_observation('metric', 2)
track.summarize_and_reset('metric')
_, result = track.summarize_and_reset('metric')
2016-10-11 22:12:10 +02:00
self.assertEqual(None, result)