@@ -274,6 +274,26 @@ def test_parse_write_no_sync_anything_else_is_false(self):
274274 write_options = client ._write_client_options .get ("write_options" )
275275 self .assertEqual (write_options .no_sync , False )
276276
277+ @patch .dict ('os.environ' , {'INFLUX_HOST' : 'localhost' , 'INFLUX_TOKEN' : 'test_token' ,
278+ 'INFLUX_DATABASE' : 'test_db' , 'INFLUX_WRITE_TIMEOUT' : '6789' })
279+ def test_parse_valid_write_timeout (self ):
280+ client = InfluxDBClient3 .from_env ()
281+ self .assertIsInstance (client , InfluxDBClient3 )
282+ write_options = client ._write_client_options .get ("write_options" )
283+ self .assertEqual (6789 , write_options .timeout )
284+
285+ @patch .dict ('os.environ' , {'INFLUX_HOST' : 'localhost' , 'INFLUX_TOKEN' : 'test_token' ,
286+ 'INFLUX_DATABASE' : 'test_db' , 'INFLUX_WRITE_TIMEOUT' : 'foo' })
287+ def test_parse_invalid_write_timeout_domain (self ):
288+ with self .assertRaisesRegex (ValueError , ".*Must be a number.*" ):
289+ InfluxDBClient3 .from_env ()
290+
291+ @patch .dict ('os.environ' , {'INFLUX_HOST' : 'localhost' , 'INFLUX_TOKEN' : 'test_token' ,
292+ 'INFLUX_DATABASE' : 'test_db' , 'INFLUX_WRITE_TIMEOUT' : '-42' })
293+ def test_parse_invalid_write_timeout_range (self ):
294+ with self .assertRaisesRegex (ValueError , ".*Must be non-negative.*" ):
295+ InfluxDBClient3 .from_env ()
296+
277297 def test_query_with_arrow_error (self ):
278298 f = ErrorFlightServer ()
279299 with InfluxDBClient3 (f"http://localhost:{ f .port } " , "my_org" , "my_db" , "my_token" ) as c :
0 commit comments