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

[Redshift] Add tests for unit testing #680

Merged
merged 10 commits into from
Feb 9, 2024
3 changes: 2 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# install latest changes in dbt-core + dbt-postgres
# TODO: how to switch from HEAD to x.y.latest branches after minor releases?
git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core
git+https://github.com/dbt-labs/dbt-postgres.git@main
git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core
git+https://github.com/dbt-labs/dbt-adapters.git
git+https://github.com/dbt-labs/dbt-adapters.git#subdirectory=dbt-tests-adapter

# if version 1.x or greater -> pin to major version
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def _plugin_version() -> str:
packages=find_namespace_packages(include=["dbt", "dbt.*"]),
include_package_data=True,
install_requires=[
"dbt-common<1.0",
"dbt-common>=0.1.0,<0.2.0",
"dbt-adapters~=0.1.0a1",
f"dbt-postgres~={_plugin_version()}",
# dbt-redshift depends deeply on this package. it does not follow SemVer, therefore there have been breaking changes in previous patch releases
Expand Down
42 changes: 42 additions & 0 deletions tests/functional/adapter/unit_testing/test_unit_testing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import pytest
from dbt.tests.adapter.unit_testing.test_types import BaseUnitTestingTypes
from dbt.tests.adapter.unit_testing.test_case_insensitivity import BaseUnitTestCaseInsensivity
from dbt.tests.adapter.unit_testing.test_invalid_input import BaseUnitTestInvalidInput


class TestRedshiftUnitTestingTypes(BaseUnitTestingTypes):
@pytest.fixture
def data_types(self):
# sql_value, yaml_value
return [
["1", "1"],
["1.0", "1.0"],
["'1'", "1"],
["'1'::numeric", "1"],
["'string'", "string"],
["true", "true"],
["DATE '2020-01-02'", "2020-01-02"],
["TIMESTAMP '2013-11-03 00:00:00-0'", "2013-11-03 00:00:00-0"],
["TIMESTAMPTZ '2013-11-03 00:00:00-0'", "2013-11-03 00:00:00-0"],
[
"""JSON_PARSE('{"bar": "baz", "balance": 7.77, "active": false}')""",
"""'{"bar": "baz", "balance": 7.77, "active": false}'""",
],
# TODO: array types
# ["ARRAY[1,2,3]", """'{1, 2, 3}'"""],
# ["ARRAY[1.0,2.0,3.0]", """'{1.0, 2.0, 3.0}'"""],
# ["ARRAY[1::numeric,2::numeric,3::numeric]", """'{1.0, 2.0, 3.0}'"""],
# ["ARRAY['a','b','c']", """'{"a", "b", "c"}'"""],
# ["ARRAY[true,true,false]", """'{true, true, false}'"""],
# ["ARRAY[DATE '2020-01-02']", """'{"2020-01-02"}'"""],
# ["ARRAY[TIMESTAMP '2013-11-03 00:00:00-0']", """'{"2013-11-03 00:00:00-0"}'"""],
# ["ARRAY[TIMESTAMPTZ '2013-11-03 00:00:00-0']", """'{"2013-11-03 00:00:00-0"}'"""],
]


class TestRedshiftUnitTestCaseInsensitivity(BaseUnitTestCaseInsensivity):
pass


class TestRedshiftUnitTestInvalidInput(BaseUnitTestInvalidInput):
pass
Loading