Debian Codegraph @

influxdb/tests/chunked_json_test.py

raw
1 # -*- coding: utf-8 -*-
2 """Chunked JSON test."""
3
4 from __future__ import absolute_import
5 from __future__ import division
6 from __future__ import print_function
7 from __future__ import unicode_literals
8
9 import unittest
10
11 from influxdb import chunked_json
12
13
14 class TestChunkJson(unittest.TestCase):
15 """Set up the TestChunkJson object."""
16
17 @classmethod
18 def setUpClass(cls):
19 """Initialize the TestChunkJson object."""
20 super(TestChunkJson, cls).setUpClass()
21
22 def test_load(self):
23 """Test reading a sequence of JSON values from a string."""
24 example_response = \
25 '{"results": [{"series": [{"measurement": "sdfsdfsdf", ' \
26 '"columns": ["time", "value"], "values": ' \
27 '[["2009-11-10T23:00:00Z", 0.64]]}]}, {"series": ' \
28 '[{"measurement": "cpu_load_short", "columns": ["time", "value"],'\
29 '"values": [["2009-11-10T23:00:00Z", 0.64]]}]}]}'
30
31 res = list(chunked_json.loads(example_response))
32 # import ipdb; ipdb.set_trace()
33
34 self.assertListEqual(
35 [
36 {
37 'results': [
38 {'series': [{
39 'values': [['2009-11-10T23:00:00Z', 0.64]],
40 'measurement': 'sdfsdfsdf',
41 'columns':
42 ['time', 'value']}]},
43 {'series': [{
44 'values': [['2009-11-10T23:00:00Z', 0.64]],
45 'measurement': 'cpu_load_short',
46 'columns': ['time', 'value']}]}
47 ]
48 }
49 ],
50 res
51 )