File tree Expand file tree Collapse file tree 10 files changed +595
-4
lines changed Expand file tree Collapse file tree 10 files changed +595
-4
lines changed Original file line number Diff line number Diff line change @@ -74,3 +74,7 @@ development =
74
74
numpy
75
75
pandas =
76
76
snowflake-connector-python[pandas]<3.0.0
77
+
78
+ [sqla_testing]
79
+ requirement_cls =snowflake.sqlalchemy.requirements:Requirements
80
+ profile_file =tests/profiles.txt
Original file line number Diff line number Diff line change
1
+ #
2
+ # Copyright (c) 2012-2022 Snowflake Computing Inc. All rights reserved.
3
+ #
4
+
5
+ from sqlalchemy .testing import exclusions
6
+ from sqlalchemy .testing .requirements import SuiteRequirements
7
+
8
+ # TODO: check through the requirement list to determine which should be turned on/off
9
+
10
+
11
+ class Requirements (SuiteRequirements ):
12
+ @property
13
+ def autocommit (self ):
14
+ return exclusions .open ()
15
+
16
+ @property
17
+ def ctes (self ):
18
+ return exclusions .open ()
19
+
20
+ @property
21
+ def ctes_on_dml (self ):
22
+ return exclusions .open ()
23
+
24
+ @property
25
+ def ctes_with_update_delete (self ):
26
+ return exclusions .open ()
27
+
28
+ @property
29
+ def delete_from (self ):
30
+ return exclusions .open ()
Original file line number Diff line number Diff line change
1
+ #
2
+ # Copyright (c) 2012-2022 Snowflake Computing Inc. All rights reserved.
3
+ #
Original file line number Diff line number Diff line change 12
12
from sqlalchemy import create_engine
13
13
14
14
import snowflake .connector
15
- from parameters import CONNECTION_PARAMETERS
16
15
from snowflake .connector .compat import IS_WINDOWS
17
16
from snowflake .sqlalchemy import URL , dialect
18
17
18
+ from .parameters import CONNECTION_PARAMETERS
19
+
19
20
CLOUD_PROVIDERS = {"aws" , "azure" , "gcp" }
20
21
EXTERNAL_SKIP_TAGS = {"internal" }
21
22
INTERNAL_SKIP_TAGS = {"external" }
Original file line number Diff line number Diff line change
1
+ # SQLAlchemy Compliance Tests
2
+
3
+ SQLAlchemy offers tests to test SQLAlchemy dialects work properly. This directory applies these tests
4
+ to the Snowflake SQLAlchemy dialect.
5
+
6
+ ** Please be aware that the test suites are not collected in pytest by default** -- the directory is ignored in ` tox.ini ` .
7
+ There are majorly three issues with the sqlalchemy test suites:
8
+ 1 . Importing sqlalchemy pytest plugin will result in Snowflake SQLAlchemy dialect specific tests not
9
+ being collected.
10
+ 2 . Putting test_suites.py and related conftest config under root tests dir would make pytest fail to collect cfg
11
+ information such as requirements, and customized session db config does not work as expected (schema not set).
12
+
13
+ Running sqlalchemy test suites from a separate directory does not have the aforementioned issues. Thus, we skip the
14
+ path in the config, and run test suites separately.
15
+
16
+ To run the SQLAlchemy test suites, please specify the directory of the test suites when running pytest command:
17
+
18
+ ``` bash
19
+ $cd snowflake-sqlalchemy
20
+ $pytest tests/sqlalchemy_test_suite
21
+ ```
Original file line number Diff line number Diff line change
1
+ #
2
+ # Copyright (c) 2012-2022 Snowflake Computing Inc. All rights reserved.
3
+ #
Original file line number Diff line number Diff line change
1
+ #
2
+ # Copyright (c) 2012-2022 Snowflake Computing Inc. All rights reserved.
3
+ #
4
+
5
+ from sqlalchemy .dialects import registry
6
+ from sqlalchemy .testing .plugin .pytestplugin import * # noqa
7
+ from sqlalchemy .testing .plugin .pytestplugin import (
8
+ pytest_sessionstart as _pytest_sessionstart ,
9
+ )
10
+
11
+ import snowflake .connector
12
+ from snowflake .sqlalchemy import URL
13
+
14
+ from ..conftest import get_db_parameters
15
+
16
+ registry .register ("snowflake" , "snowflake.sqlalchemy" , "dialect" )
17
+ registry .register ("snowflake.snowflake" , "snowflake.sqlalchemy" , "dialect" )
18
+
19
+
20
+ def pytest_sessionstart (session ):
21
+ db_parameters = get_db_parameters ()
22
+ session .config .option .dburi = [URL (** db_parameters )]
23
+ # schema name with 'TEST_SCHEMA' is required by some tests of the sqlalchemy test suite
24
+ with snowflake .connector .connect (** db_parameters ) as con :
25
+ con .cursor ().execute ("CREATE SCHEMA IF NOT EXISTS TEST_SCHEMA" )
26
+ _pytest_sessionstart (session )
You can’t perform that action at this time.
0 commit comments