Exemplo n.º 1
0
def test_snowflake_fetchall(client):
    add_snowflake_query_response(
        rowtype=["TEXT"],
        rows=[("4.30.2", )],
    )
    with client.cursor() as cur:
        res = cur.execute("select current_version();")
        assert res == cur
        assert cur.fetchall() == [("4.30.2", )]
Exemplo n.º 2
0
def test_snowflake_pin_override(client):
    add_snowflake_query_response(
        rowtype=["TEXT"],
        rows=[("4.30.2", )],
    )
    Pin(service="pin-sv", tags={"custom": "tag"}).onto(client)
    with client.cursor() as cur:
        res = cur.execute("select current_version();")
        assert res == cur
        assert cur.fetchone() == ("4.30.2", )
Exemplo n.º 3
0
def test_snowflake_analytics_without_rate(client):
    add_snowflake_query_response(
        rowtype=["TEXT"],
        rows=[("4.30.2", )],
    )
    with override_config("snowflake", dict(analytics_enabled=True)):
        with client.cursor() as cur:
            res = cur.execute("select current_version();")
            assert res == cur
            assert cur.fetchone() == ("4.30.2", )
Exemplo n.º 4
0
def test_snowflake_settings_override(client):
    add_snowflake_query_response(
        rowtype=["TEXT"],
        rows=[("4.30.2", )],
    )
    with override_config("snowflake", dict(service="my-snowflake-svc")):
        with client.cursor() as cur:
            res = cur.execute("select current_version();")
            assert res == cur
            assert cur.fetchone() == ("4.30.2", )
Exemplo n.º 5
0
def test_snowflake_fetchall_multiple_rows(client):
    add_snowflake_query_response(
        rowtype=["TEXT", "TEXT"],
        rows=[("1a", "1b"), ("2a", "2b")],
    )
    with client.cursor() as cur:
        res = cur.execute("select a, b from t;")
        assert res == cur
        assert cur.fetchall() == [
            ("1a", "1b"),
            ("2a", "2b"),
        ]
Exemplo n.º 6
0
def test_snowflake_executemany_insert(client):
    add_snowflake_query_response(
        rowtype=[],
        rows=[],
        total=2,
    )
    with client.cursor() as cur:
        res = cur.executemany(
            "insert into t (a, b) values (%s, %s);",
            [
                ("1a", "1b"),
                ("2a", "2b"),
            ],
        )
        assert res == cur
        assert res.rowcount == 2
Exemplo n.º 7
0
def test_snowflake_service_env():
    from tests.contrib.snowflake.test_snowflake import _client
    from tests.contrib.snowflake.test_snowflake import add_snowflake_query_response
    from tests.contrib.snowflake.test_snowflake import req_mock

    with _client() as c:
        with req_mock:
            add_snowflake_query_response(
                rowtype=["TEXT"],
                rows=[("4.30.2", )],
            )

            with c.cursor() as cur:
                res = cur.execute("select current_version();")
                assert res == cur
                assert cur.fetchone() == ("4.30.2", )
Exemplo n.º 8
0
def test_snowflake_rollback(client):
    add_snowflake_query_response(rowtype=[], rows=[])
    client.rollback()
Exemplo n.º 9
0
def test_snowflake_commit(client):
    add_snowflake_query_response(rowtype=[], rows=[])
    client.commit()