Skip to content

Commit

Permalink
Setup shared tests (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare authored Feb 21, 2024
1 parent 086fa8b commit 57d2e70
Show file tree
Hide file tree
Showing 28 changed files with 1,300 additions and 5 deletions.
23 changes: 18 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ path = "dbt/adapters/postgres/__version__.py"
[tool.hatch.envs.default]
dependencies = [
"dbt-adapters @ git+https://github.com/dbt-labs/dbt-adapters.git",
"dbt_common @ git+https://github.com/dbt-labs/dbt-common.git",
"dbt-common @ git+https://github.com/dbt-labs/dbt-common.git",
]

[tool.hatch.envs.lint]
Expand Down Expand Up @@ -81,22 +81,34 @@ all = "python -m mypy ."

[tool.hatch.envs.unit-tests]
dependencies = [
# TODO: remove `dbt-core` dependencies from unit tests
"dbt-core @ git+https://github.com/dbt-labs/dbt-core.git#subdirectory=core",
"freezegun",
"pytest",
"pytest-dotenv",
"pytest-mock",
"pytest-xdist",
]
extra-dependencies = [
# TODO: remove `dbt-core` dependencies from unit tests
"dbt-adapters @ git+https://github.com/dbt-labs/dbt-adapters.git",
"dbt-common @ git+https://github.com/dbt-labs/dbt-common.git",
"dbt-core @ git+https://github.com/dbt-labs/dbt-core.git#subdirectory=core",
]
[tool.hatch.envs.unit-tests.scripts]
all = "python -m pytest {args:tests/unit}"

[tool.hatch.envs.integration-tests]
template = "unit-tests"
extra-dependencies = [
# TODO: remove `dbt-core` dependencies from integration tests
"dbt-adapters @ git+https://github.com/dbt-labs/dbt-adapters.git",
"dbt-common @ git+https://github.com/dbt-labs/dbt-common.git",
"dbt-core @ git+https://github.com/dbt-labs/dbt-core.git#subdirectory=core",
"dbt-tests-adapter @ git+https://github.com/dbt-labs/dbt-adapters.git#subdirectory=dbt-tests-adapter",
]
[tool.hatch.envs.integration-tests.env-vars]
DBT_TEST_USER_1 = "dbt_test_user_1"
DBT_TEST_USER_2 = "dbt_test_user_2"
DBT_TEST_USER_3 = "dbt_test_user_3"
[tool.hatch.envs.integration-tests.scripts]
all = "python -m pytest {args:tests/functional}"

Expand Down Expand Up @@ -130,7 +142,7 @@ target-version = ['py38']
[tool.flake8]
select = ["E", "W", "F"]
ignore = ["E203", "E501", "E741", "W503", "W504"]
exclude = ["tests", "venv"]
exclude = ["tests", "venv", ".hatch_venvs"]
per-file-ignores = ["*/__init__.py: F401"]

[tool.mypy]
Expand All @@ -145,7 +157,8 @@ files = [
]
exclude = [
"tests/functional",
"venv"
"venv",
".hatch_venvs",
]

[tool.pytest]
Expand Down
4 changes: 4 additions & 0 deletions test.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,7 @@ POSTGRES_TEST_USER=
POSTGRES_TEST_PASS=
POSTGRES_TEST_DATABASE=
POSTGRES_TEST_THREADS=

DBT_TEST_USER_1=dbt_test_user_1
DBT_TEST_USER_2=dbt_test_user_2
DBT_TEST_USER_3=dbt_test_user_3
1 change: 1 addition & 0 deletions tests/functional/shared_tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# this file namespaces the test files within to avoid naming collision for the test collector
501 changes: 501 additions & 0 deletions tests/functional/shared_tests/seed_bom.csv

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions tests/functional/shared_tests/test_aliases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from dbt.tests.adapter.aliases.test_aliases import (
BaseAliases,
BaseAliasErrors,
BaseSameAliasDifferentSchemas,
BaseSameAliasDifferentDatabases,
)


class TestAliases(BaseAliases):
pass


class TestAliasErrors(BaseAliasErrors):
pass


class TestSameAliasDifferentSchemas(BaseSameAliasDifferentSchemas):
pass


class TestSameAliasDifferentDatabases(BaseSameAliasDifferentDatabases):
pass
79 changes: 79 additions & 0 deletions tests/functional/shared_tests/test_basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
from dbt.tests.adapter.basic.test_adapter_methods import BaseAdapterMethod
from dbt.tests.adapter.basic.test_base import BaseSimpleMaterializations
from dbt.tests.adapter.basic.test_docs_generate import (
BaseDocsGenerate,
BaseDocsGenReferences,
)
from dbt.tests.adapter.basic.test_empty import BaseEmpty
from dbt.tests.adapter.basic.test_ephemeral import BaseEphemeral
from dbt.tests.adapter.basic.test_generic_tests import BaseGenericTests
from dbt.tests.adapter.basic.test_incremental import (
BaseIncremental,
BaseIncrementalNotSchemaChange,
)
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_snapshot_check_cols import BaseSnapshotCheckCols
from dbt.tests.adapter.basic.test_snapshot_timestamp import BaseSnapshotTimestamp
from dbt.tests.adapter.basic.test_table_materialization import BaseTableMaterialization
from dbt.tests.adapter.basic.test_validate_connection import BaseValidateConnection


class TestBaseCaching(BaseAdapterMethod):
pass


class TestSimpleMaterializations(BaseSimpleMaterializations):
pass


class TestDocsGenerate(BaseDocsGenerate):
pass


class TestDocsGenReferences(BaseDocsGenReferences):
pass


class TestEmpty(BaseEmpty):
pass


class TestEphemeral(BaseEphemeral):
pass


class TestGenericTests(BaseGenericTests):
pass


class TestIncremental(BaseIncremental):
pass


class TestBaseIncrementalNotSchemaChange(BaseIncrementalNotSchemaChange):
pass


class TestSingularTests(BaseSingularTests):
pass


class TestSingularTestsEphemeral(BaseSingularTestsEphemeral):
pass


class TestSnapshotCheckCols(BaseSnapshotCheckCols):
pass


class TestSnapshotTimestamp(BaseSnapshotTimestamp):
pass


class TestTableMat(BaseTableMaterialization):
pass


class TestValidateConnection(BaseValidateConnection):
pass
22 changes: 22 additions & 0 deletions tests/functional/shared_tests/test_caching.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from dbt.tests.adapter.caching.test_caching import (
BaseCachingLowercaseModel,
BaseCachingSelectedSchemaOnly,
BaseCachingUppercaseModel,
BaseNoPopulateCache,
)


class TestCachingLowerCaseModel(BaseCachingLowercaseModel):
pass


class TestCachingUppercaseModel(BaseCachingUppercaseModel):
pass


class TestCachingSelectedSchemaOnly(BaseCachingSelectedSchemaOnly):
pass


class TestNoPopulateCache(BaseNoPopulateCache):
pass
20 changes: 20 additions & 0 deletions tests/functional/shared_tests/test_clone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pytest

from dbt.tests.adapter.dbt_clone.test_dbt_clone import (
BaseCloneNotPossible,
BaseClonePossible,
BaseCloneSameTargetAndState,
)


class TestBaseCloneNotPossible(BaseCloneNotPossible):
pass


@pytest.mark.skip("Cloning is not possible in Postgres")
class TestBaseClonePossible(BaseClonePossible):
pass


class TestCloneSameTargetAndState(BaseCloneSameTargetAndState):
pass
5 changes: 5 additions & 0 deletions tests/functional/shared_tests/test_column_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from dbt.tests.adapter.column_types.test_column_types import BaseColumnTypes


class TestPostgresColumnTypes(BaseColumnTypes):
pass
5 changes: 5 additions & 0 deletions tests/functional/shared_tests/test_concurrency.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from dbt.tests.adapter.concurrency.test_concurrency import BaseConcurrency


class TestConcurrency(BaseConcurrency):
pass
64 changes: 64 additions & 0 deletions tests/functional/shared_tests/test_constraints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from dbt.tests.adapter.constraints.test_constraints import (
BaseTableConstraintsColumnsEqual,
BaseViewConstraintsColumnsEqual,
BaseIncrementalConstraintsColumnsEqual,
BaseConstraintsRuntimeDdlEnforcement,
BaseConstraintsRollback,
BaseIncrementalConstraintsRuntimeDdlEnforcement,
BaseIncrementalConstraintsRollback,
BaseTableContractSqlHeader,
BaseIncrementalContractSqlHeader,
BaseModelConstraintsRuntimeEnforcement,
BaseConstraintQuotedColumn,
BaseIncrementalForeignKeyConstraint,
)


class TestTableConstraintsColumnsEqual(BaseTableConstraintsColumnsEqual):
pass


class TestViewConstraintsColumnsEqual(BaseViewConstraintsColumnsEqual):
pass


class TestIncrementalConstraintsColumnsEqual(BaseIncrementalConstraintsColumnsEqual):
pass


class TestTableConstraintsRuntimeDdlEnforcement(BaseConstraintsRuntimeDdlEnforcement):
pass


class TestTableConstraintsRollback(BaseConstraintsRollback):
pass


class TestIncrementalConstraintsRuntimeDdlEnforcement(
BaseIncrementalConstraintsRuntimeDdlEnforcement
):
pass


class TestIncrementalConstraintsRollback(BaseIncrementalConstraintsRollback):
pass


class TestTableContractSqlHeader(BaseTableContractSqlHeader):
pass


class TestIncrementalContractSqlHeader(BaseIncrementalContractSqlHeader):
pass


class TestModelConstraintsRuntimeEnforcement(BaseModelConstraintsRuntimeEnforcement):
pass


class TestConstraintQuotedColumn(BaseConstraintQuotedColumn):
pass


class TestIncrementalForeignKeyConstraint(BaseIncrementalForeignKeyConstraint):
pass
35 changes: 35 additions & 0 deletions tests/functional/shared_tests/test_data_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
from dbt.tests.adapter.utils.data_types.test_type_bigint import BaseTypeBigInt
from dbt.tests.adapter.utils.data_types.test_type_boolean import BaseTypeBoolean
from dbt.tests.adapter.utils.data_types.test_type_float import BaseTypeFloat
from dbt.tests.adapter.utils.data_types.test_type_int import BaseTypeInt
from dbt.tests.adapter.utils.data_types.test_type_numeric import BaseTypeNumeric
from dbt.tests.adapter.utils.data_types.test_type_string import BaseTypeString
from dbt.tests.adapter.utils.data_types.test_type_timestamp import BaseTypeTimestamp


class TestTypeBigInt(BaseTypeBigInt):
pass


class TestTypeBoolean(BaseTypeBoolean):
pass


class TestTypeFloat(BaseTypeFloat):
pass


class TestTypeInt(BaseTypeInt):
pass


class TestTypeNumeric(BaseTypeNumeric):
pass


class TestTypeString(BaseTypeString):
pass


class TestTypeTimestamp(BaseTypeTimestamp):
pass
12 changes: 12 additions & 0 deletions tests/functional/shared_tests/test_debug.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from dbt.tests.adapter.dbt_debug.test_dbt_debug import (
BaseDebugPostgres,
BaseDebugInvalidProjectPostgres,
)


class TestDebugPostgres(BaseDebugPostgres):
pass


class TestDebugInvalidProjectPostgres(BaseDebugInvalidProjectPostgres):
pass
5 changes: 5 additions & 0 deletions tests/functional/shared_tests/test_empty.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from dbt.tests.adapter.empty.test_empty import BaseTestEmpty


class TestEmpty(BaseTestEmpty):
pass
17 changes: 17 additions & 0 deletions tests/functional/shared_tests/test_ephemeral.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from dbt.tests.adapter.ephemeral.test_ephemeral import (
BaseEphemeralMulti,
BaseEphemeralNested,
BaseEphemeralErrorHandling,
)


class TestEphemeralMulti(BaseEphemeralMulti):
pass


class TestEphemeralNested(BaseEphemeralNested):
pass


class TestEphemeralErrorHandling(BaseEphemeralErrorHandling):
pass
25 changes: 25 additions & 0 deletions tests/functional/shared_tests/test_grants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from dbt.tests.adapter.grants.test_incremental_grants import BaseIncrementalGrants
from dbt.tests.adapter.grants.test_invalid_grants import BaseInvalidGrants
from dbt.tests.adapter.grants.test_model_grants import BaseModelGrants
from dbt.tests.adapter.grants.test_seed_grants import BaseSeedGrants
from dbt.tests.adapter.grants.test_snapshot_grants import BaseSnapshotGrants


class TestIncrementalGrants(BaseIncrementalGrants):
pass


class TestInvalidGrants(BaseInvalidGrants):
pass


class TestModelGrants(BaseModelGrants):
pass


class TestSeedGrants(BaseSeedGrants):
pass


class TestSnapshotGrants(BaseSnapshotGrants):
pass
Loading

0 comments on commit 57d2e70

Please sign in to comment.