Skip to content

Commit 9b753de

Browse files
committed
update client tests for line protocol
1 parent 078350e commit 9b753de

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

tests/influxdb/client_test.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def test_write(self):
139139
with requests_mock.Mocker() as m:
140140
m.register_uri(
141141
requests_mock.POST,
142-
"http://localhost:8086/write",
142+
"http://localhost:8086/write_points",
143143
status_code=204
144144
)
145145
cli = InfluxDBClient(database='db')
@@ -154,21 +154,15 @@ def test_write(self):
154154
)
155155

156156
self.assertEqual(
157-
json.loads(m.last_request.body),
158-
{"database": "mydb",
159-
"retentionPolicy": "mypolicy",
160-
"points": [{"measurement": "cpu_load_short",
161-
"tags": {"host": "server01",
162-
"region": "us-west"},
163-
"timestamp": "2009-11-10T23:00:00Z",
164-
"fields": {"value": 0.64}}]}
157+
m.last_request.body,
158+
b"cpu_load_short,host=server01,region=us-west value=0.64 1257890400000000000\n",
165159
)
166160

167161
def test_write_points(self):
168162
with requests_mock.Mocker() as m:
169163
m.register_uri(
170164
requests_mock.POST,
171-
"http://localhost:8086/write",
165+
"http://localhost:8086/write_points",
172166
status_code=204
173167
)
174168

@@ -188,7 +182,7 @@ def test_write_points_toplevel_attributes(self):
188182
with requests_mock.Mocker() as m:
189183
m.register_uri(
190184
requests_mock.POST,
191-
"http://localhost:8086/write",
185+
"http://localhost:8086/write_points",
192186
status_code=204
193187
)
194188

@@ -227,7 +221,7 @@ def test_write_points_batch(self):
227221
"fields": {"value": 12.00}}]}
228222
with requests_mock.Mocker() as m:
229223
m.register_uri(requests_mock.POST,
230-
"http://localhost:8086/write",
224+
"http://localhost:8086/write_points",
231225
status_code=204)
232226
cli = InfluxDBClient(database='db')
233227
cli.write_points(points=dummy_points,
@@ -284,7 +278,7 @@ def test_write_points_with_precision(self):
284278
with requests_mock.Mocker() as m:
285279
m.register_uri(
286280
requests_mock.POST,
287-
"http://localhost:8086/write",
281+
"http://localhost:8086/write_points",
288282
status_code=204
289283
)
290284

@@ -294,12 +288,9 @@ def test_write_points_with_precision(self):
294288
time_precision='n'
295289
)
296290

297-
self.assertDictEqual(
298-
{'points': self.dummy_points,
299-
'database': 'db',
300-
'precision': 'n',
301-
},
302-
json.loads(m.last_request.body)
291+
self.assertEqual(
292+
b"cpu_load_short,host=server01,region=us-west value=0.64 1257890400000000000\n",
293+
m.last_request.body,
303294
)
304295

305296
def test_write_points_bad_precision(self):

0 commit comments

Comments
 (0)