Skip to content

Commit

Permalink
Initial use of adapter test framework (#106)
Browse files Browse the repository at this point in the history
  • Loading branch information
gshank authored Mar 29, 2022
1 parent 8d9f1af commit 71f133f
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
3 changes: 2 additions & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 10 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -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
22 changes: 22 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -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'),
}


49 changes: 49 additions & 0 deletions tests/functional/adapter/test_basic.py
Original file line number Diff line number Diff line change
@@ -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
8 changes: 1 addition & 7 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 71f133f

Please sign in to comment.