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

29 lines
885 B
Python
Raw Normal View History

from lbrynet.extras.daemon import analytics
2016-09-30 06:26:27 +02:00
2019-01-22 23:54:25 +01:00
import unittest
2016-09-30 06:26:27 +02:00
2019-01-22 23:54:25 +01:00
@unittest.SkipTest
2016-09-30 06:26:27 +02:00
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')
self.assertIsNone(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')
self.assertIsNone(result)