Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Beginning to reorg the functional tests #492

Merged
merged 1 commit into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions tests/functional/adapter/aliases/fixtures.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# macros #
MACROS__CAST_SQL = """
{% macro string_literal(s) -%}
{{ adapter.dispatch('string_literal', macro_namespace='test')(s) }}
{%- endmacro %}

{% macro databricks__string_literal(s) %}
cast('{{ s }}' as STRING)
{% endmacro %}
"""
40 changes: 40 additions & 0 deletions tests/functional/adapter/aliases/test_aliases.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from dbt.tests.adapter.aliases.test_aliases import (
BaseAliases,
BaseAliasErrors,
BaseSameAliasDifferentSchemas,
BaseSameAliasDifferentDatabases,
)
from dbt.tests.adapter.aliases import fixtures as dbt_fixtures
import pytest

from tests.functional.adapter.aliases import fixtures as databricks_fixtures


macro_override = {
"cast.sql": databricks_fixtures.MACROS__CAST_SQL,
"expect_value.sql": dbt_fixtures.MACROS__EXPECT_VALUE_SQL,
}


class TestDatabricksAliases(BaseAliases):
@pytest.fixture(scope="class")
def macros(self):
return macro_override


class TestDatabricksAliasErrors(BaseAliasErrors):
@pytest.fixture(scope="class")
def macros(self):
return macro_override


class TestDatabricksSameAliasDifferentSchemas(BaseSameAliasDifferentSchemas):
@pytest.fixture(scope="class")
def macros(self):
return macro_override


class TestDatabricksSameAliasDifferentDatabases(BaseSameAliasDifferentDatabases):
@pytest.fixture(scope="class")
def macros(self):
return macro_override
5 changes: 5 additions & 0 deletions tests/functional/adapter/basic/test_base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from dbt.tests.adapter.basic.test_base import BaseSimpleMaterializations


class TestDatabricksSimpleMaterializations(BaseSimpleMaterializations):
pass
Original file line number Diff line number Diff line change
@@ -1,81 +1,28 @@
import pytest

from dbt.tests.adapter.basic.expected_catalog import base_expected_catalog
from dbt.tests.util import AnyInteger, AnyString

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, BaseIncrementalNotSchemaChange
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
from dbt.tests.adapter.basic.test_adapter_methods import BaseAdapterMethod
from dbt.tests.adapter.basic import expected_catalog
from dbt.tests.adapter.basic.test_docs_generate import BaseDocsGenerate, BaseDocsGenReferences
from dbt.tests.util import AnyString

import pytest

class TestSimpleMaterializationsDatabricks(BaseSimpleMaterializations):
pass


class TestSingularTestsDatabricks(BaseSingularTests):
pass


class TestSingularTestsEphemeralDatabricks(BaseSingularTestsEphemeral):
pass


class TestEmptyDatabricks(BaseEmpty):
pass


class TestEphemeralDatabricks(BaseEphemeral):
pass


class TestIncrementalDatabricks(BaseIncremental):
pass


class TestIncrementalNotSchemaChangeDatabricks(BaseIncrementalNotSchemaChange):
pass


class TestGenericTestsDatabricks(BaseGenericTests):
pass


class TestSnapshotCheckColsDatabricks(BaseSnapshotCheckCols):
pass


class TestSnapshotTimestampDatabricks(BaseSnapshotTimestamp):
pass


class TestBaseAdapterMethodDatabricks(BaseAdapterMethod):
pass
from tests.functional.adapter.basic.typing import AnyLongType, StatsLikeDict


class TestDocsGenerateDatabricks(BaseDocsGenerate):
class TestDatabricksDocsGenerate(BaseDocsGenerate):
@pytest.fixture(scope="class")
def expected_catalog(self, project):
return base_expected_catalog(
return expected_catalog.base_expected_catalog(
project,
role=AnyString(),
id_type=AnyLongType(),
text_type="string",
time_type="timestamp",
view_type="view",
table_type="table",
model_stats=_StatsLikeDict(),
model_stats=StatsLikeDict(),
)


class TestDocsGenReferencesDatabricks(BaseDocsGenReferences):
class TestDatabricksDocsGenReferences(BaseDocsGenReferences):
@pytest.fixture(scope="class")
def expected_catalog(self, project):
return self.expected_references_catalog(
Expand All @@ -87,7 +34,7 @@ def expected_catalog(self, project):
bigint_type=AnyLongType(),
view_type="view",
table_type="table",
model_stats=_StatsLikeDict(),
model_stats=StatsLikeDict(),
)

# Temporary until upstream fixes to allow 0-based indexing
Expand Down Expand Up @@ -214,30 +161,3 @@ def expected_references_catalog(
},
},
}


class _StatsLikeDict:
"""Any stats-like dict. Use this in assert calls"""

def __eq__(self, other):
return (
isinstance(other, dict)
and "has_stats" in other
and (
other["has_stats"]
== {
"id": "has_stats",
"label": "Has Stats?",
"value": AnyInteger(),
"description": "Indicates whether there are statistics for this table",
"include": False,
}
)
)


class AnyLongType:
"""Allows bigint and long to be treated equivalently"""

def __eq__(self, other):
return isinstance(other, str) and other in ("bigint", "long")
5 changes: 5 additions & 0 deletions tests/functional/adapter/basic/test_empty.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from dbt.tests.adapter.basic.test_empty import BaseEmpty


class TestDatabricksEmpty(BaseEmpty):
pass
5 changes: 5 additions & 0 deletions tests/functional/adapter/basic/test_ephemeral.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from dbt.tests.adapter.basic.test_ephemeral import BaseEphemeral


class TestDatabricksEphemeral(BaseEphemeral):
pass
5 changes: 5 additions & 0 deletions tests/functional/adapter/basic/test_generic_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from dbt.tests.adapter.basic.test_generic_tests import BaseGenericTests


class TestDatabricksGenericTests(BaseGenericTests):
pass
9 changes: 9 additions & 0 deletions tests/functional/adapter/basic/test_incremental.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from dbt.tests.adapter.basic.test_incremental import BaseIncremental, BaseIncrementalNotSchemaChange


class TestDatabricksIncremental(BaseIncremental):
pass


class TestDatabricksIncrementalNotSchemaChange(BaseIncrementalNotSchemaChange):
pass
5 changes: 5 additions & 0 deletions tests/functional/adapter/basic/test_singular_tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from dbt.tests.adapter.basic.test_singular_tests import BaseSingularTests


class TestDatabricksSingularTests(BaseSingularTests):
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from dbt.tests.adapter.basic.test_singular_tests_ephemeral import BaseSingularTestsEphemeral


class TestDatabricksSingularTestsEphemeral(BaseSingularTestsEphemeral):
pass
5 changes: 5 additions & 0 deletions tests/functional/adapter/basic/test_snapshot_check_cols.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from dbt.tests.adapter.basic.test_snapshot_check_cols import BaseSnapshotCheckCols


class TestDatabricksSnapshotCheckCols(BaseSnapshotCheckCols):
pass
5 changes: 5 additions & 0 deletions tests/functional/adapter/basic/test_snapshot_timestamp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from dbt.tests.adapter.basic.test_snapshot_timestamp import BaseSnapshotTimestamp


class TestDatabricksSnapshotTimestamp(BaseSnapshotTimestamp):
pass
28 changes: 28 additions & 0 deletions tests/functional/adapter/basic/typing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from dbt.tests.util import AnyInteger


class StatsLikeDict:
"""Any stats-like dict. Use this in assert calls"""

def __eq__(self, other):
return (
isinstance(other, dict)
and "has_stats" in other
and (
other["has_stats"]
== {
"id": "has_stats",
"label": "Has Stats?",
"value": AnyInteger(),
"description": "Indicates whether there are statistics for this table",
"include": False,
}
)
)


class AnyLongType:
"""Allows bigint and long to be treated equivalently"""

def __eq__(self, other):
return isinstance(other, str) and other in ("bigint", "long")
13 changes: 13 additions & 0 deletions tests/functional/adapter/ephemeral/test_ephemeral_multi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from dbt.tests.adapter.ephemeral.test_ephemeral import BaseEphemeralMulti
from dbt.tests import util


class TestDatabricksEphemeralMulti(BaseEphemeralMulti):
def test_ephemeral_multi(self, project):
util.run_dbt(["seed"])
results = util.run_dbt(["run"])
assert len(results) == 3

util.check_relations_equal(project.adapter, ["seed", "dependent"])
util.check_relations_equal(project.adapter, ["seed", "double_dependent"])
util.check_relations_equal(project.adapter, ["seed", "super_dependent"])
13 changes: 0 additions & 13 deletions tests/functional/adapter/test_ephemeral.py

This file was deleted.

Loading