|
3 | 3 | import unittest
|
4 | 4 |
|
5 | 5 | from influxdb.resultset import ResultSet
|
6 |
| -from influxdb.point import Point |
7 | 6 |
|
8 | 7 |
|
9 | 8 | class TestResultSet(unittest.TestCase):
|
@@ -40,36 +39,22 @@ def test_filter_by_name(self):
|
40 | 39 | self.assertEqual(
|
41 | 40 | list(self.rs['cpu_load_short']),
|
42 | 41 | [
|
43 |
| - Point("cpu_load_short", ["time", "value"], |
44 |
| - ["2015-01-29T21:51:28.968422294Z", 0.64], |
45 |
| - tags={"host": "server01", "region": "us-west"}), |
46 |
| - Point("cpu_load_short", ["time", "value"], |
47 |
| - ["2015-01-29T21:51:28.968422294Z", 0.64], |
48 |
| - tags={"host": "server02", "region": "us-west"}) |
| 42 | + {'value': 0.64, 'time': '2015-01-29T21:51:28.968422294Z'}, |
| 43 | + {'value': 0.64, 'time': '2015-01-29T21:51:28.968422294Z'} |
49 | 44 | ]
|
50 | 45 | )
|
51 | 46 |
|
52 | 47 | def test_filter_by_tags(self):
|
53 | 48 | self.assertEqual(
|
54 | 49 | list(self.rs[('cpu_load_short', {"host": "server01"})]),
|
55 |
| - [ |
56 |
| - Point( |
57 |
| - "cpu_load_short", ["time", "value"], |
58 |
| - ["2015-01-29T21:51:28.968422294Z", 0.64], |
59 |
| - tags={"host": "server01", "region": "us-west"} |
60 |
| - ) |
61 |
| - ] |
| 50 | + [{'time': '2015-01-29T21:51:28.968422294Z', 'value': 0.64}] |
62 | 51 | )
|
63 | 52 |
|
64 | 53 | self.assertEqual(
|
65 | 54 | list(self.rs[('cpu_load_short', {"region": "us-west"})]),
|
66 | 55 | [
|
67 |
| - Point("cpu_load_short", ["time", "value"], |
68 |
| - ["2015-01-29T21:51:28.968422294Z", 0.64], |
69 |
| - tags={"host": "server01", "region": "us-west"}), |
70 |
| - Point("cpu_load_short", ["time", "value"], |
71 |
| - ["2015-01-29T21:51:28.968422294Z", 0.64], |
72 |
| - tags={"host": "server02", "region": "us-west"}), |
| 56 | + {'value': 0.64, 'time': '2015-01-29T21:51:28.968422294Z'}, |
| 57 | + {'value': 0.64, 'time': '2015-01-29T21:51:28.968422294Z'} |
73 | 58 | ]
|
74 | 59 | )
|
75 | 60 |
|
@@ -98,21 +83,25 @@ def test_items(self):
|
98 | 83 | [
|
99 | 84 | (
|
100 | 85 | ('cpu_load_short', {'host': 'server01', 'region': 'us-west'}),
|
101 |
| - [Point("cpu_load_short", ["time", "value"], |
102 |
| - ["2015-01-29T21:51:28.968422294Z", 0.64], |
103 |
| - tags={"host": "server01", "region": "us-west"})] |
| 86 | + [{'value': 0.64, 'time': '2015-01-29T21:51:28.968422294Z'}] |
104 | 87 | ),
|
105 | 88 | (
|
106 | 89 | ('cpu_load_short', {'host': 'server02', 'region': 'us-west'}),
|
107 |
| - [Point("cpu_load_short", ["time", "value"], |
108 |
| - ["2015-01-29T21:51:28.968422294Z", 0.64], |
109 |
| - tags={"host": "server02", "region": "us-west"})] |
| 90 | + [{'value': 0.64, 'time': '2015-01-29T21:51:28.968422294Z'}] |
110 | 91 | ),
|
111 | 92 | (
|
112 | 93 | ('other_serie', {'host': 'server01', 'region': 'us-west'}),
|
113 |
| - [Point("other_serie", ["time", "value"], |
114 |
| - ["2015-01-29T21:51:28.968422294Z", 0.64], |
115 |
| - tags={"host": "server01", "region": "us-west"})] |
| 94 | + [{'value': 0.64, 'time': '2015-01-29T21:51:28.968422294Z'}] |
116 | 95 | )
|
117 | 96 | ]
|
118 | 97 | )
|
| 98 | + |
| 99 | + def test_point_from_cols_vals(self): |
| 100 | + cols = ['col1', 'col2'] |
| 101 | + vals = [1, '2'] |
| 102 | + |
| 103 | + point = ResultSet.point_from_cols_vals(cols, vals) |
| 104 | + self.assertDictEqual( |
| 105 | + point, |
| 106 | + {'col1': 1, 'col2': '2'} |
| 107 | + ) |
0 commit comments