@@ -74,8 +74,7 @@ def test_warn_trusted_connection_username_pass(instance_minimal_defaults, cs, us
74
74
instance_minimal_defaults ["connection_string" ] = cs
75
75
instance_minimal_defaults ["username" ] = username
76
76
instance_minimal_defaults ["password" ] = password
77
- check = SQLServer (CHECK_NAME , {}, [instance_minimal_defaults ])
78
- connection = Connection (check .resolved_hostname , {}, instance_minimal_defaults , None )
77
+ connection = Connection ({}, instance_minimal_defaults , None )
79
78
connection .log = mock .MagicMock ()
80
79
connection ._connection_options_validation ('somekey' , 'somedb' )
81
80
if expect_warning :
@@ -97,8 +96,7 @@ def test_warn_trusted_connection_username_pass(instance_minimal_defaults, cs, us
97
96
)
98
97
def test_will_warn_parameters_for_the_wrong_connection (instance_minimal_defaults , connector , param ):
99
98
instance_minimal_defaults .update ({'connector' : connector , param : 'foo' })
100
- check = SQLServer (CHECK_NAME , {}, [instance_minimal_defaults ])
101
- connection = Connection (check .resolved_hostname , {}, instance_minimal_defaults , None )
99
+ connection = Connection ({}, instance_minimal_defaults , None )
102
100
connection .log = mock .MagicMock ()
103
101
connection ._connection_options_validation ('somekey' , 'somedb' )
104
102
connection .log .warning .assert_called_once_with (
@@ -130,8 +128,7 @@ def test_will_warn_parameters_for_the_wrong_connection(instance_minimal_defaults
130
128
)
131
129
def test_will_fail_for_duplicate_parameters (instance_minimal_defaults , connector , cs , param , should_fail ):
132
130
instance_minimal_defaults .update ({'connector' : connector , param : 'foo' , 'connection_string' : cs + "=foo" })
133
- check = SQLServer (CHECK_NAME , {}, [instance_minimal_defaults ])
134
- connection = Connection (check .resolved_hostname , {}, instance_minimal_defaults , None )
131
+ connection = Connection ({}, instance_minimal_defaults , None )
135
132
if should_fail :
136
133
match = (
137
134
"%s has been provided both in the connection string and as a configuration option (%s), "
@@ -162,8 +159,7 @@ def test_will_fail_for_duplicate_parameters(instance_minimal_defaults, connector
162
159
def test_will_fail_for_wrong_parameters_in_the_connection_string (instance_minimal_defaults , connector , cs ):
163
160
instance_minimal_defaults .update ({'connector' : connector , 'connection_string' : cs + '=foo' })
164
161
other_connector = 'odbc' if connector != 'odbc' else 'adodbapi'
165
- check = SQLServer (CHECK_NAME , {}, [instance_minimal_defaults ])
166
- connection = Connection (check .resolved_hostname , {}, instance_minimal_defaults , None )
162
+ connection = Connection ({}, instance_minimal_defaults , None )
167
163
match = (
168
164
"%s has been provided in the connection string. "
169
165
"This option is only available for %s connections, however %s has been selected"
@@ -226,8 +222,7 @@ def test_managed_auth_config_valid(instance_minimal_defaults, name, managed_iden
226
222
for k , v in managed_identity_config .items ():
227
223
instance_minimal_defaults [k ] = v
228
224
instance_minimal_defaults .update ({'connector' : 'odbc' })
229
- check = SQLServer (CHECK_NAME , {}, [instance_minimal_defaults ])
230
- connection = Connection (check .resolved_hostname , {}, instance_minimal_defaults , None )
225
+ connection = Connection ({}, instance_minimal_defaults , None )
231
226
if should_fail :
232
227
with pytest .raises (ConfigurationError , match = re .escape (expected_err )):
233
228
connection ._connection_options_validation ('somekey' , 'somedb' )
@@ -287,8 +282,7 @@ def test_managed_auth_config_valid(instance_minimal_defaults, name, managed_iden
287
282
def test_config_with_and_without_port (instance_minimal_defaults , host , port , expected_host ):
288
283
instance_minimal_defaults ["host" ] = host
289
284
instance_minimal_defaults ["port" ] = port
290
- check = SQLServer (CHECK_NAME , {}, [instance_minimal_defaults ])
291
- connection = Connection (check .resolved_hostname , {}, instance_minimal_defaults , None )
285
+ connection = Connection ({}, instance_minimal_defaults , None )
292
286
_ , result_host , _ , _ , _ , _ = connection ._get_access_info ('somekey' , 'somedb' )
293
287
assert result_host == expected_host
294
288
@@ -369,9 +363,7 @@ def test_connection_failure(aggregator, dd_run_check, instance_docker):
369
363
370
364
try :
371
365
# Break the connection
372
- check .connection = Connection (
373
- check .resolved_hostname , {}, {'host' : '' , 'username' : '' , 'password' : '' }, check .handle_service_check
374
- )
366
+ check .connection = Connection ({}, {'host' : '' , 'username' : '' , 'password' : '' }, check .handle_service_check )
375
367
dd_run_check (check )
376
368
except Exception :
377
369
aggregator .assert_service_check (
@@ -495,7 +487,7 @@ def test_connection_error_reporting(
495
487
expected_error_pattern = matching_patterns [0 ]
496
488
497
489
check = SQLServer (CHECK_NAME , {}, [instance_docker ])
498
- connection = Connection (check .resolved_hostname , check . init_config , check .instance , check .handle_service_check )
490
+ connection = Connection (check .init_config , check .instance , check .handle_service_check )
499
491
with pytest .raises (SQLConnectionError ) as excinfo :
500
492
with connection .open_managed_default_connection ():
501
493
pytest .fail ("connection should not have succeeded" )
0 commit comments