@@ -152,26 +152,65 @@ def test_from_env_missing_variables(self):
152152 self .assertIn ("Missing required environment variables" , str (context .exception ))
153153
154154 @patch .dict ('os.environ' , {'INFLUX_HOST' : 'localhost' , 'INFLUX_TOKEN' : 'test_token' ,
155- 'INFLUX_DATABASE' : 'test_db' , 'INFLUX_PRECISION' : WritePrecision .MS })
155+ 'INFLUX_DATABASE' : 'test_db' , 'INFLUX_PRECISION' : WritePrecision .S })
156156 def test_parse_valid_write_precision (self ):
157157 client = InfluxDBClient3 .from_env ()
158158 self .assertIsInstance (client , InfluxDBClient3 )
159- self .assertEqual (client ._write_client_options .get ('write_options' ).write_precision , WritePrecision .MS )
159+ self .assertEqual (client ._write_client_options .get ('write_options' ).write_precision , WritePrecision .S )
160160
161161 @patch .dict ('os.environ' , {'INFLUX_HOST' : 'localhost' , 'INFLUX_TOKEN' : 'test_token' ,
162162 'INFLUX_DATABASE' : 'test_db' , 'INFLUX_PRECISION' : "microsecond" })
163- def test_parse_valid_long_write_precision (self ):
163+ def test_parse_valid_long_write_precision_us (self ):
164164 client = InfluxDBClient3 .from_env ()
165165 self .assertIsInstance (client , InfluxDBClient3 )
166166 self .assertEqual (client ._write_client_options .get ('write_options' ).write_precision , WritePrecision .US )
167167
168+ @patch .dict ('os.environ' , {'INFLUX_HOST' : 'localhost' , 'INFLUX_TOKEN' : 'test_token' ,
169+ 'INFLUX_DATABASE' : 'test_db' , 'INFLUX_PRECISION' : "nanosecond" })
170+ def test_parse_valid_long_write_precision_ns (self ):
171+ client = InfluxDBClient3 .from_env ()
172+ self .assertIsInstance (client , InfluxDBClient3 )
173+ self .assertEqual (client ._write_client_options .get ('write_options' ).write_precision , WritePrecision .NS )
174+
168175 @patch .dict ('os.environ' , {'INFLUX_HOST' : 'localhost' , 'INFLUX_TOKEN' : 'test_token' ,
169176 'INFLUX_DATABASE' : 'test_db' , 'INFLUX_PRECISION' : 'invalid_value' })
170177 def test_parse_invalid_write_precision (self ):
171178 with self .assertRaises (ValueError ) as context :
172179 InfluxDBClient3 .from_env ()
173180 self .assertIn ("Invalid precision value: invalid_value" , str (context .exception ))
174181
182+ @patch .dict ('os.environ' , {'INFLUX_HOST' : 'localhost' , 'INFLUX_TOKEN' : 'test_token' ,
183+ 'INFLUX_DATABASE' : 'test_db' , 'INFLUX_WRITE_NO_SYNC' : 'true' })
184+ def test_parse_write_no_sync_true (self ):
185+ client = InfluxDBClient3 .from_env ()
186+ self .assertIsInstance (client , InfluxDBClient3 )
187+ write_options = client ._write_client_options .get ("write_options" )
188+ self .assertEqual (write_options .no_sync , True )
189+
190+ @patch .dict ('os.environ' , {'INFLUX_HOST' : 'localhost' , 'INFLUX_TOKEN' : 'test_token' ,
191+ 'INFLUX_DATABASE' : 'test_db' , 'INFLUX_WRITE_NO_SYNC' : 'TrUe' })
192+ def test_parse_write_no_sync_true_mixed_chars (self ):
193+ client = InfluxDBClient3 .from_env ()
194+ self .assertIsInstance (client , InfluxDBClient3 )
195+ write_options = client ._write_client_options .get ("write_options" )
196+ self .assertEqual (write_options .no_sync , True )
197+
198+ @patch .dict ('os.environ' , {'INFLUX_HOST' : 'localhost' , 'INFLUX_TOKEN' : 'test_token' ,
199+ 'INFLUX_DATABASE' : 'test_db' , 'INFLUX_WRITE_NO_SYNC' : 'false' })
200+ def test_parse_write_no_sync_false (self ):
201+ client = InfluxDBClient3 .from_env ()
202+ self .assertIsInstance (client , InfluxDBClient3 )
203+ write_options = client ._write_client_options .get ("write_options" )
204+ self .assertEqual (write_options .no_sync , False )
205+
206+ @patch .dict ('os.environ' , {'INFLUX_HOST' : 'localhost' , 'INFLUX_TOKEN' : 'test_token' ,
207+ 'INFLUX_DATABASE' : 'test_db' , 'INFLUX_WRITE_NO_SYNC' : 'anything-else' })
208+ def test_parse_write_no_sync_anything_else_is_false (self ):
209+ client = InfluxDBClient3 .from_env ()
210+ self .assertIsInstance (client , InfluxDBClient3 )
211+ write_options = client ._write_client_options .get ("write_options" )
212+ self .assertEqual (write_options .no_sync , False )
213+
175214 def test_query_with_arrow_error (self ):
176215 f = ErrorFlightServer ()
177216 with InfluxDBClient3 (f"http://localhost:{ f .port } " , "my_org" , "my_db" , "my_token" ) as c :
0 commit comments