forked from LBRYCommunity/lbry-sdk
27 lines
871 B
Python
27 lines
871 B
Python
from lbrynet import analytics
|
|
|
|
from twisted.trial import unittest
|
|
|
|
|
|
class TrackTest(unittest.TestCase):
|
|
def test_empty_summarize_is_none(self):
|
|
track = analytics.Manager(None, 'x', 'y', 'z')
|
|
_, result = track.summarize_and_reset('a')
|
|
self.assertIsNone(result)
|
|
|
|
def test_can_get_sum_of_metric(self):
|
|
track = analytics.Manager(None, 'x', 'y', 'z')
|
|
track.add_observation('b', 1)
|
|
track.add_observation('b', 2)
|
|
|
|
_, result = track.summarize_and_reset('b')
|
|
self.assertEqual(3, result)
|
|
|
|
def test_summarize_resets_metric(self):
|
|
track = analytics.Manager(None, 'x', 'y', 'z')
|
|
track.add_observation('metric', 1)
|
|
track.add_observation('metric', 2)
|
|
|
|
track.summarize_and_reset('metric')
|
|
_, result = track.summarize_and_reset('metric')
|
|
self.assertIsNone(result)
|