def it_should_create_connection_string_with_encrypt_keyword() -> None: expected_connection_string = "mssql+pyodbc://c,1/d?Encrypt=yes&driver=ODBC+Driver+17+for+SQL+Server" actual = sql_adapter.create_mssql_adapter_with_integrated_security( "c", "d", 1, True ) assert str(actual.engine.url) == expected_connection_string
def it_should_raise_an_error() -> None: with pytest.raises(Exception): adapter = sql_adapter.create_mssql_adapter_with_integrated_security( "localhost", "master") adapter.execute([ sql_adapter.Statement("SELECT 1/0", "divide by zero") ])
def build_mssql_adapter_with_integrated_security(self) -> None: self.db_adapter = create_mssql_adapter_with_integrated_security( self.server, self.db_name, self._get_sql_server_port(), self.encrypt, self.trust_certificate, )
def it_should_create_an_engine_with_proper_connection_string() -> None: expected_connection_string = ( "mssql+pyodbc://c,1/d?driver=ODBC+Driver+17+for+SQL+Server" ) actual = sql_adapter.create_mssql_adapter_with_integrated_security( "c", "d", 1 ) assert str(actual.engine.url) == expected_connection_string
def _new_mssql_adapter(request) -> Adapter: use_integrated_security = request.config.getoption( "--useintegratedsecurity") server = request.config.getoption("--server") port = request.config.getoption("--port") db_name = request.config.getoption("--dbname") username = request.config.getoption("--username") password = request.config.getoption("--password") if use_integrated_security is True: return create_mssql_adapter_with_integrated_security( server, db_name, port, False, False) return create_mssql_adapter(username, password, server, db_name, port)
def it_should_not_throw_an_error() -> None: adapter = sql_adapter.create_mssql_adapter_with_integrated_security( "localhost", "master") adapter.execute( [sql_adapter.Statement("SELECT 1/1", "info message")])