@@ -88,6 +88,9 @@ def test_write_num_py(self):
88
88
89
89
pass
90
90
91
+
92
+ class DataSerializerTest (unittest .TestCase ):
93
+
91
94
def test_write_nan (self ):
92
95
from influxdb_client .extras import pd , np
93
96
@@ -129,8 +132,6 @@ def test_write_tag_nan(self):
129
132
now + timedelta (minutes = 60 ), now + timedelta (minutes = 90 )],
130
133
columns = ["tag" , "actual_kw_price" , "forecast_kw_price" ])
131
134
132
- write_api = self .client .write_api (write_options = SYNCHRONOUS , point_settings = PointSettings ())
133
-
134
135
points = data_frame_to_list_of_points (data_frame = data_frame ,
135
136
point_settings = PointSettings (),
136
137
data_frame_measurement_name = 'measurement' ,
@@ -146,8 +147,6 @@ def test_write_tag_nan(self):
146
147
self .assertEqual ("measurement,tag=tag actual_kw_price=3.138664,forecast_kw_price=20.755026 1586050200000000000" ,
147
148
points [3 ])
148
149
149
- write_api .__del__ ()
150
-
151
150
def test_escaping_measurement (self ):
152
151
from influxdb_client .extras import pd , np
153
152
@@ -214,3 +213,24 @@ def test_tags_order(self):
214
213
215
214
self .assertEqual (1 , len (points ))
216
215
self .assertEqual ("h2o,a=a,b=b,c=c level=2i 1586048400000000000" , points [0 ])
216
+
217
+ def test_escape_text_value (self ):
218
+ from influxdb_client .extras import pd , np
219
+
220
+ now = pd .Timestamp ('2020-04-05 00:00+00:00' )
221
+ an_hour_ago = now - timedelta (hours = 1 )
222
+
223
+ test = [{'a' : an_hour_ago , 'b' : 'hello world' , 'c' : 1 , 'd' : 'foo bar' },
224
+ {'a' : now , 'b' : 'goodbye cruel world' , 'c' : 2 , 'd' : 'bar foo' }]
225
+
226
+ data_frame = pd .DataFrame (test )
227
+ data_frame = data_frame .set_index ('a' )
228
+
229
+ points = data_frame_to_list_of_points (data_frame = data_frame ,
230
+ point_settings = PointSettings (),
231
+ data_frame_measurement_name = 'test' ,
232
+ data_frame_tag_columns = ['d' ])
233
+
234
+ self .assertEqual (2 , len (points ))
235
+ self .assertEqual ("test,d=foo\\ bar b=\" hello world\" ,c=1i 1586041200000000000" , points [0 ])
236
+ self .assertEqual ("test,d=bar\\ foo b=\" goodbye cruel world\" ,c=2i 1586044800000000000" , points [1 ])
0 commit comments