Skip to content
Snippets Groups Projects
Commit 4dacccd8 authored by Piotr Maślanka's avatar Piotr Maślanka
Browse files

add extra test for timestamp exports

parent 65aad937
No related branches found
No related tags found
No related merge requests found
......@@ -20,11 +20,11 @@ class RendererObject(io.StringIO):
if is_leaf_node(tree):
self.write('_'.join(prefix for prefix in prefixes if prefix != ''))
curly_braces_used = len(tree) > 1
if curly_braces_used:
self.write('{')
main_value = tree.pop('_')
ts = tree.pop('_timestamp', None)
curly_braces_used = len(tree) > 0
if curly_braces_used:
self.write('{')
if curly_braces_used:
labels = []
for key, value in tree.items():
......
......@@ -7,6 +7,10 @@ logger = logging.getLogger(__name__)
class TestExporters(unittest.TestCase):
def test_prometheus_timestamps(self):
a = {'root': {'_': 5, '_timestamp': 10}}
self.assertEqual("""root 5 10000\n""", json_to_prometheus(a))
def test_prometheus(self):
a = {'root': {'metric': [{'k': 2, '_': 3, 'm': '"'}, {'k': 4, '_': 6}]}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment