OpenMetrics Tests WIP

This commit is contained in:
Florian Sesser 2021-09-10 00:10:11 +00:00
parent 30771149fc
commit fca1482b35

View File

@ -1,4 +1,6 @@
import mock
from twisted.trial import unittest from twisted.trial import unittest
from allmydata.web.status import Statistics
class FakeStatsProvider(object): class FakeStatsProvider(object):
def get_stats(self): def get_stats(self):
@ -6,6 +8,18 @@ class FakeStatsProvider(object):
return stats return stats
class OpenMetrics(unittest.TestCase): class OpenMetrics(unittest.TestCase):
def test_spec_compliance(self): def test_header(self):
self.assertEqual('1', '2') req = mock.Mock()
stats = mock.Mock()
stats._provider = FakeStatsProvider()
metrics = Statistics.render_OPENMETRICS(stats, req)
req.setHeader.assert_called_with("content-type", "application/openmetrics-text; version=1.0.0; charset=utf-8")
def test_spec_compliance(self):
req = mock.Mock()
stats = mock.Mock()
stats._provider = FakeStatsProvider()
metrics = Statistics.render_OPENMETRICS(stats, req)
# TODO test that output adheres to spec
# TODO add more realistic stats, incl. missing (None) values