@@ -59,6 +59,28 @@ def test_write_points_from_dataframe(self):
59
59
cli .write_points (dataframe , 'foo' , tags = None )
60
60
self .assertEqual (m .last_request .body , expected )
61
61
62
+ def test_dataframe_write_points_with_whitespace_measurement (self ):
63
+ """write_points should escape white space in measurements."""
64
+ now = pd .Timestamp ('1970-01-01 00:00+00:00' )
65
+ dataframe = pd .DataFrame (data = [["1" , 1 , 1.0 ], ["2" , 2 , 2.0 ]],
66
+ index = [now , now + timedelta (hours = 1 )],
67
+ columns = ["column_one" , "column_two" ,
68
+ "column_three" ])
69
+ expected = (
70
+ b"meas\\ with\\ space "
71
+ b"column_one=\" 1\" ,column_two=1i,column_three=1.0 0\n "
72
+ b"meas\\ with\\ space "
73
+ b"column_one=\" 2\" ,column_two=2i,column_three=2.0 "
74
+ b"3600000000000\n "
75
+ )
76
+ with requests_mock .Mocker () as m :
77
+ m .register_uri (requests_mock .POST ,
78
+ "http://localhost:8086/write" ,
79
+ status_code = 204 )
80
+ cli = DataFrameClient (database = 'db' )
81
+ cli .write_points (dataframe , 'meas with space' )
82
+ self .assertEqual (m .last_request .body , expected )
83
+
62
84
def test_write_points_from_dataframe_with_none (self ):
63
85
"""Test write points from df in TestDataFrameClient object."""
64
86
now = pd .Timestamp ('1970-01-01 00:00+00:00' )
0 commit comments