@@ -77,6 +77,20 @@ def test_write_with_no_sync_true(self, httpserver: HTTPServer):
7777 method = "POST" , uri = "/api/v3/write_lp" ,
7878 query_string = {"org" : "ORG" , "db" : "DB" , "precision" : "microsecond" , "no_sync" : "true" }))
7979
80+ def test_write_with_no_sync_true_in_kwargs (self , httpserver : HTTPServer ):
81+ self .set_response_status (httpserver , 200 )
82+
83+ InfluxDBClient3 (
84+ host = (httpserver .url_for ("/" )), org = "ORG" , database = "DB" , token = "TOKEN" ,
85+ write_client_options = write_client_options (
86+ write_options = WriteOptions (write_type = WriteType .synchronous , write_precision = WritePrecision .US )
87+ )
88+ ).write (self .SAMPLE_RECORD , no_sync = True )
89+
90+ self .assert_request_made (httpserver , RequestMatcher (
91+ method = "POST" , uri = "/api/v3/write_lp" ,
92+ query_string = {"org" : "ORG" , "db" : "DB" , "precision" : "microsecond" , "no_sync" : "true" }))
93+
8094 def test_write_with_accept_partial_false (self , httpserver : HTTPServer ):
8195 self .set_response_status (httpserver , 200 )
8296
@@ -113,6 +127,20 @@ def test_write_with_use_v2_api_true(self, httpserver: HTTPServer):
113127 method = "POST" , uri = "/api/v2/write" ,
114128 query_string = {"org" : "ORG" , "bucket" : "DB" , "precision" : "us" }))
115129
130+ def test_write_with_use_v2_api_true_in_kwargs (self , httpserver : HTTPServer ):
131+ self .set_response_status (httpserver , 200 )
132+
133+ InfluxDBClient3 (
134+ host = (httpserver .url_for ("/" )), org = "ORG" , database = "DB" , token = "TOKEN" ,
135+ write_client_options = write_client_options (
136+ write_options = WriteOptions (write_type = WriteType .synchronous , write_precision = WritePrecision .US )
137+ )
138+ ).write (self .SAMPLE_RECORD , use_v2_api = True , accept_partial = False )
139+
140+ self .assert_request_made (httpserver , RequestMatcher (
141+ method = "POST" , uri = "/api/v2/write" ,
142+ query_string = {"org" : "ORG" , "bucket" : "DB" , "precision" : "us" }))
143+
116144 def test_write_with_v3_on_v2_server (self , httpserver : HTTPServer ):
117145 self .set_response_status (httpserver , HTTPStatus .METHOD_NOT_ALLOWED )
118146
@@ -186,6 +214,17 @@ def test_write_invalid_use_v2_api_and_no_sync(self, httpserver: HTTPServer):
186214 with pytest .raises (ValueError , match = r".*invalid write options: no_sync cannot be used with use_v2_api.*" ):
187215 client .write (self .SAMPLE_RECORD )
188216
217+ def test_write_invalid_use_v2_api_and_no_sync_in_kwargs (self , httpserver : HTTPServer ):
218+ client = InfluxDBClient3 (
219+ host = (httpserver .url_for ("/" )), org = "ORG" , database = "DB" , token = "TOKEN" ,
220+ write_client_options = write_client_options (
221+ write_options = WriteOptions (write_type = WriteType .synchronous )
222+ )
223+ )
224+
225+ with pytest .raises (ValueError , match = r".*invalid write options: no_sync cannot be used with use_v2_api.*" ):
226+ client .write (self .SAMPLE_RECORD , use_v2_api = True , no_sync = True )
227+
189228 def test_write_with_timeout_in_write_options (self , httpserver : HTTPServer ):
190229 self .delay_response (httpserver , 0.5 )
191230
0 commit comments