2019-06-21 03:02:58 +02:00
|
|
|
from lbry.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')
|
2016-10-18 23:49:31 +02:00
|
|
|
_, result = track.summarize_and_reset('a')
|
2018-10-18 13:41:33 +02:00
|
|
|
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)
|
|
|
|
|
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):
|
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)
|
|
|
|
|
2016-10-18 23:49:31 +02:00
|
|
|
track.summarize_and_reset('metric')
|
|
|
|
_, result = track.summarize_and_reset('metric')
|
2018-10-18 13:41:33 +02:00
|
|
|
self.assertIsNone(result)
|