From 71f133fbe9ad57f4814249ce56411af4a4e343c1 Mon Sep 17 00:00:00 2001 From: Gerda Shank Date: Tue, 29 Mar 2022 11:47:45 -0400 Subject: [PATCH] Initial use of adapter test framework (#106) --- CHANGELOG.md | 1 + dev_requirements.txt | 3 +- pytest.ini | 10 ++++++ tests/conftest.py | 22 ++++++++++++ tests/functional/adapter/test_basic.py | 49 ++++++++++++++++++++++++++ tox.ini | 8 +---- 6 files changed, 85 insertions(+), 8 deletions(-) create mode 100644 pytest.ini create mode 100644 tests/conftest.py create mode 100644 tests/functional/adapter/test_basic.py diff --git a/CHANGELOG.md b/CHANGELOG.md index cc8ef1c3b..c7cec0658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Change logic for Post-failure job run ([#67](https://github.com/dbt-labs/dbt-snowflake/pull/67)) - Update to version bumping script ([#68](https://github.com/dbt-labs/dbt-snowflake/pull/68)) - Add contributing.md file for snowflake adapter repo ([#79](https://github.com/dbt-labs/dbt-snowflake/pull/79)) +- Use dbt.tests.adapter.basic in test suite (new test framework) ([#105](https://github.com/dbt-labs/dbt-snowflake/issues/105), [#106](https://github.com/dbt-labs/dbt-snowflake/pull/106)) ### Contributors - [@joshuataylor](https://github.com/joshuataylor) ([#40](https://github.com/dbt-labs/dbt-snowflake/pull/40)) diff --git a/dev_requirements.txt b/dev_requirements.txt index e0641f9c9..79fc271d7 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,6 +1,7 @@ # install latest changes in dbt-core # TODO: how to automate switching from develop to version branches? -git+https://github.com/dbt-labs/dbt.git#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter bumpversion flake8 diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 000000000..b04a6ccf3 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,10 @@ +[pytest] +filterwarnings = + ignore:.*'soft_unicode' has been renamed to 'soft_str'*:DeprecationWarning + ignore:unclosed file .*:ResourceWarning +env_files = + test.env +testpaths = + tests/unit + tests/integration + tests/functional diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 000000000..3efc1305d --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,22 @@ +import pytest +import os + +# Import the fuctional fixtures as a plugin +# Note: fixtures with session scope need to be local + +pytest_plugins = ["dbt.tests.fixtures.project"] + +# The profile dictionary, used to write out profiles.yml +@pytest.fixture(scope="class") +def dbt_profile_target(): + return { + 'type': 'snowflake', + 'threads': 4, + 'account': os.getenv('SNOWFLAKE_TEST_ACCOUNT'), + 'user': os.getenv('SNOWFLAKE_TEST_USER'), + 'password': os.getenv('SNOWFLAKE_TEST_PASSWORD'), + 'database': os.getenv('SNOWFLAKE_TEST_DATABASE'), + 'warehouse': os.getenv('SNOWFLAKE_TEST_WAREHOUSE'), + } + + diff --git a/tests/functional/adapter/test_basic.py b/tests/functional/adapter/test_basic.py new file mode 100644 index 000000000..09ddf3d57 --- /dev/null +++ b/tests/functional/adapter/test_basic.py @@ -0,0 +1,49 @@ +import pytest + +from dbt.tests.adapter.basic.test_base import BaseSimpleMaterializations +from dbt.tests.adapter.basic.test_singular_tests import BaseSingularTests +from dbt.tests.adapter.basic.test_singular_tests_ephemeral import ( + BaseSingularTestsEphemeral, +) +from dbt.tests.adapter.basic.test_empty import BaseEmpty +from dbt.tests.adapter.basic.test_ephemeral import BaseEphemeral +from dbt.tests.adapter.basic.test_incremental import BaseIncremental +from dbt.tests.adapter.basic.test_generic_tests import BaseGenericTests +from dbt.tests.adapter.basic.test_snapshot_check_cols import BaseSnapshotCheckCols +from dbt.tests.adapter.basic.test_snapshot_timestamp import BaseSnapshotTimestamp + + +class TestSimpleMaterializationsSnowflake(BaseSimpleMaterializations): + pass + + +class TestSingularTestsSnowflake(BaseSingularTests): + pass + + +class TestSingularTestsEphemeralSnowflake(BaseSingularTestsEphemeral): + pass + + +class TestEmptySnowflake(BaseEmpty): + pass + + +class TestEphemeralSnowflake(BaseEphemeral): + pass + + +class TestIncrementalSnowflake(BaseIncremental): + pass + + +class TestGenericTestsSnowflake(BaseGenericTests): + pass + + +class TestSnapshotCheckColsSnowflake(BaseSnapshotCheckCols): + pass + + +class TestSnapshotTimestampSnowflake(BaseSnapshotTimestamp): + pass diff --git a/tox.ini b/tox.ini index 5c8a61229..9e6e264b3 100644 --- a/tox.ini +++ b/tox.ini @@ -26,13 +26,7 @@ skip_install = true passenv = DBT_* SNOWFLAKE_TEST_* PYTEST_ADDOPTS commands = snowflake: {envpython} -m pytest {posargs} -m profile_snowflake tests/integration + snowflake: {envpython} -m pytest {posargs} tests/functional deps = -rdev_requirements.txt -e. - -[pytest] -env_files = - test.env -testpaths = - tests/unit - tests/integration