77from pytz import UTC , timezone
88
99from influxdb_client import Point , WritePrecision
10- from tests .base_test import BaseTest
1110
1211
13- class PointTest (BaseTest ):
12+ class PointTest (unittest . TestCase ):
1413
1514 def test_MeasurementEscape (self ):
1615 point = Point .measurement ("h2 o" ).tag ("location" , "europe" ).tag ("" , "warn" ).field ("level" , 2 )
@@ -153,6 +152,20 @@ def test_TimeSpanFormatting(self):
153152
154153 self .assertEqual ("h2o,location=europe level=2i 123" , point .to_line_protocol ())
155154
155+ point = Point .measurement ("h2o" ) \
156+ .tag ("location" , "europe" ) \
157+ .field ("level" , 2 ) \
158+ .time (timedelta (microseconds = 876 ), WritePrecision .NS )
159+
160+ self .assertEqual ("h2o,location=europe level=2i 876000" , point .to_line_protocol ())
161+
162+ point = Point .measurement ("h2o" ) \
163+ .tag ("location" , "europe" ) \
164+ .field ("level" , 2 ) \
165+ .time (timedelta (milliseconds = 954 ), WritePrecision .NS )
166+
167+ self .assertEqual ("h2o,location=europe level=2i 954000000" , point .to_line_protocol ())
168+
156169 def test_DateTimeFormatting (self ):
157170 date_time = datetime (2015 , 10 , 15 , 8 , 20 , 15 )
158171
@@ -172,6 +185,27 @@ def test_DateTimeFormatting(self):
172185
173186 self .assertEqual ("h2o,location=europe level=false 1444897215" , point .to_line_protocol ())
174187
188+ point = Point .measurement ("h2o" ) \
189+ .tag ("location" , "europe" ) \
190+ .field ("level" , False ) \
191+ .time (date_time , WritePrecision .MS )
192+
193+ self .assertEqual ("h2o,location=europe level=false 1444897215000" , point .to_line_protocol ())
194+
195+ point = Point .measurement ("h2o" ) \
196+ .tag ("location" , "europe" ) \
197+ .field ("level" , False ) \
198+ .time (date_time , WritePrecision .US )
199+
200+ self .assertEqual ("h2o,location=europe level=false 1444897215000750" , point .to_line_protocol ())
201+
202+ point = Point .measurement ("h2o" ) \
203+ .tag ("location" , "europe" ) \
204+ .field ("level" , False ) \
205+ .time (date_time , WritePrecision .NS )
206+
207+ self .assertEqual ("h2o,location=europe level=false 1444897215000750000" , point .to_line_protocol ())
208+
175209 point = Point .measurement ("h2o" ) \
176210 .tag ("location" , "europe" ) \
177211 .field ("level" , True ) \
0 commit comments