Exemplo n.º 1
0
def sql_creds():
    return SqlCreds(
        server=docker_db_obj.address,
        database=_db_name,
        username="******",
        password=docker_db_obj.sa_sql_password,
    )
Exemplo n.º 2
0
def test_sql_creds_for_windows_auth_non_default_port():
    """
    Tests that the SqlCreds object can be created without Username and Password (Windows Auth)
    """
    creds = SqlCreds(server="test_server", database="test_database", driver_version=99, port=9999,)
    assert creds.port == 9999
    assert creds.with_krb_auth is True
    assert isinstance(creds.engine, engine.Connectable)
    assert str(creds.engine.url) == (
        "mssql+pyodbc:///?odbc_connect="
        "Driver={ODBC Driver 99 for SQL Server};Server=tcp:test_server,9999;Database=test_database;Trusted_Connection=yes;"
    )
Exemplo n.º 3
0
def test_sql_creds_for_windows_auth_blank_port():
    """
    Tests that the SqlCreds object can be created
    
    * Without Username and Password (Windows Auth)
    * Use blank port
    """
    creds = SqlCreds(server="test_server", database="test_database", driver_version=99, port=None,)
    assert creds.port is None
    assert str(creds.engine.url) == (
        "mssql+pyodbc:///?odbc_connect="
        "Driver={ODBC Driver 99 for SQL Server};Server=tcp:test_server;Database=test_database;Trusted_Connection=yes;"
    )
Exemplo n.º 4
0
def test_sql_creds_for_username_password_non_default_port():
    """
    Tests that the SqlCreds object can be created with Username and Password (SQL Auth)
    """
    creds = SqlCreds(
        server="test_server",
        database="test_database",
        username="******",
        password="******",
        driver_version=99,
        port=9999,
    )
    assert creds.port == 9999
    assert creds.with_krb_auth is False
    assert isinstance(creds.engine, engine.Connectable)
    assert str(creds.engine.url) == _quote_engine_url(
        "Driver={ODBC Driver 99 for SQL Server};Server=tcp:test_server,9999;Database=test_database;"
        "UID=test_user;PWD=test_password"
    )
Exemplo n.º 5
0
def test_sql_creds_for_windows_auth():
    """
    Tests that the SqlCreds object can be created without Username and Password (Windows Auth)
    """
    creds = SqlCreds(
        server="test_server",
        database="test_database",
        driver_version=99,
    )
    assert creds.server == "test_server"
    assert creds.database == "test_database"
    assert creds.username == ""
    assert creds.password == ""
    assert creds.port == 1433
    assert creds.with_krb_auth is True
    assert isinstance(creds.engine, engine.Connectable)
    assert str(creds.engine.url) == _quote_engine_url(
        "Driver={ODBC Driver 99 for SQL Server};Server=tcp:test_server,1433;Database=test_database;Trusted_Connection=yes;"
    )
Exemplo n.º 6
0
def test_sql_creds_for_username_password_blank_port():
    """
    Tests that the SqlCreds object can be created with Username and Password (SQL Auth) and blank Port

    * With Username and Password
    * Use blank port
    """
    creds = SqlCreds(
        server="test_server",
        database="test_database",
        username="******",
        password="******",
        driver_version=99,
        port=None,
    )
    assert creds.port is None
    assert str(creds.engine.url) == _quote_engine_url(
        "Driver={ODBC Driver 99 for SQL Server};Server=tcp:test_server;Database=test_database;"
        "UID=test_user;PWD=test_password"
    )
Exemplo n.º 7
0
def test_sql_creds_for_username_password():
    """
    Tests that the SqlCreds object can be created with Username and Password (SQL Auth)
    """
    creds = SqlCreds(
        server="test_server",
        database="test_database",
        username="******",
        password="******",
        driver_version=99,
    )
    assert creds.server == "test_server"
    assert creds.database == "test_database"
    assert creds.username == "test_user"
    assert creds.password == "test_password"
    assert creds.port == 1433
    assert creds.with_krb_auth is False
    assert isinstance(creds.engine, engine.Connectable)
    assert str(creds.engine.url) == (
        "mssql+pyodbc:///?odbc_connect="
        "Driver={ODBC Driver 99 for SQL Server};Server=tcp:test_server,1433;Database=test_database;"
        "UID=test_user;PWD=test_password"
    )