@@ -207,13 +207,11 @@ def test_write_points_batch(self):
207
207
{"measurement" : "network" , "tags" : {"direction" : "out" },
208
208
"time" : "2009-11-10T23:00:00Z" , "fields" : {"value" : 12.00 }}
209
209
]
210
- expected_last_body = {"tags" : {"host" : "server01" ,
211
- "region" : "us-west" },
212
- "database" : "db" ,
213
- "points" : [{"measurement" : "network" ,
214
- "tags" : {"direction" : "out" },
215
- "time" : "2009-11-10T23:00:00Z" ,
216
- "fields" : {"value" : 12.00 }}]}
210
+ expected_last_body = (
211
+ "network,direction=out,host=server01,region=us-west "
212
+ "value=12.0 1257894000000000000\n "
213
+ )
214
+
217
215
with requests_mock .Mocker () as m :
218
216
m .register_uri (requests_mock .POST ,
219
217
"http://localhost:8086/write" ,
@@ -225,7 +223,7 @@ def test_write_points_batch(self):
225
223
"region" : "us-west" },
226
224
batch_size = 2 )
227
225
self .assertEqual (m .call_count , 2 )
228
- self .assertEqual (expected_last_body , m .last_request .json () )
226
+ self .assertEqual (expected_last_body , m .last_request .body )
229
227
230
228
def test_write_points_udp (self ):
231
229
s = socket .socket (socket .AF_INET , socket .SOCK_DGRAM )
@@ -240,12 +238,10 @@ def test_write_points_udp(self):
240
238
241
239
received_data , addr = s .recvfrom (1024 )
242
240
243
- self .assertDictEqual (
244
- {
245
- "points" : self .dummy_points ,
246
- "database" : "test"
247
- },
248
- json .loads (received_data .decode (), strict = True )
241
+ self .assertEqual (
242
+ "cpu_load_short,host=server01,region=us-west "
243
+ "value=0.64 1257894000000000000\n " ,
244
+ received_data .decode ()
249
245
)
250
246
251
247
def test_write_bad_precision_udp (self ):
0 commit comments