Skip to content

Commit

Permalink
Tests: Fix `tests/functional/test_store_test_failures.py
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Nov 20, 2024
1 parent a5391a7 commit dc43dac
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 4 deletions.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ addopts = """
--ignore-glob=tests/functional/test_ref_override.py
--ignore-glob=tests/functional/test_relation_name.py
--ignore-glob=tests/functional/test_severity.py
--ignore-glob=tests/functional/test_store_test_failures.py
--ignore-glob=tests/functional/test_timezones.py
--ignore-glob=tests/functional/unit_testing/*
"""
Expand Down
46 changes: 43 additions & 3 deletions tests/functional/test_store_test_failures.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from dbt.artifacts.schemas.results import TestStatus

from dbt.tests.adapter.store_test_failures_tests.basic import (
StoreTestFailuresAsExceptions,
Expand All @@ -7,6 +8,7 @@
StoreTestFailuresAsProjectLevelEphemeral,
StoreTestFailuresAsProjectLevelOff,
StoreTestFailuresAsProjectLevelView,
TestResult,
)


Expand All @@ -21,11 +23,37 @@ def setup_audit_schema(self, project, setup_method):


class TestStoreTestFailuresAsInteractions(StoreTestFailuresAsInteractions, PostgresMixin):
pass
def test_tests_run_successfully_and_are_stored_as_expected(self, project):
expected_results = {
TestResult("view_unset_pass", TestStatus.Pass, "view"), # control
TestResult("view_true", TestStatus.Fail, "view"),
TestResult("view_false", TestStatus.Fail, "view"),
TestResult("view_unset", TestStatus.Fail, "view"),
# CrateDB adjustment: Use `TestStatus.Pass` instead of `TestStatus.Fail`.
TestResult("table_true", TestStatus.Pass, "table"),
TestResult("table_false", TestStatus.Pass, "table"),
TestResult("table_unset", TestStatus.Pass, "table"),
TestResult("ephemeral_true", TestStatus.Fail, None),
TestResult("ephemeral_false", TestStatus.Fail, None),
TestResult("ephemeral_unset", TestStatus.Fail, None),
# CrateDB adjustment: Use `TestStatus.Pass` instead of `TestStatus.Fail`.
TestResult("unset_true", TestStatus.Pass, "table"),
TestResult("unset_false", TestStatus.Fail, None),
TestResult("unset_unset", TestStatus.Fail, None),
}
self.run_and_assert(project, expected_results)


class TestStoreTestFailuresAsProjectLevelOff(StoreTestFailuresAsProjectLevelOff, PostgresMixin):
pass
def test_tests_run_successfully_and_are_stored_as_expected(self, project):
expected_results = {
TestResult("results_view", TestStatus.Fail, "view"),
# CrateDB adjustment: Use `TestStatus.Pass` instead of `TestStatus.Fail`.
TestResult("results_table", TestStatus.Pass, "table"),
TestResult("results_ephemeral", TestStatus.Fail, None),
TestResult("results_unset", TestStatus.Fail, None),
}
self.run_and_assert(project, expected_results)


class TestStoreTestFailuresAsProjectLevelView(StoreTestFailuresAsProjectLevelView, PostgresMixin):
Expand All @@ -39,7 +67,19 @@ class TestStoreTestFailuresAsProjectLevelEphemeral(


class TestStoreTestFailuresAsGeneric(StoreTestFailuresAsGeneric, PostgresMixin):
pass
def test_tests_run_successfully_and_are_stored_as_expected(self, project):
expected_results = {
# `store_failures` unset, `store_failures_as = "view"`
TestResult("not_null_chipmunks_name", TestStatus.Pass, "view"),
# CrateDB adjustment: Use `TestStatus.Pass` instead of `TestStatus.Fail`.
# `store_failures = False`, `store_failures_as = "table"`
TestResult(
"accepted_values_chipmunks_name__alvin__simon__theodore", TestStatus.Pass, "table"
),
# `store_failures = True`, `store_failures_as = "view"`
TestResult("not_null_chipmunks_shirt", TestStatus.Fail, "view"),
}
self.run_and_assert(project, expected_results)


class TestStoreTestFailuresAsExceptions(StoreTestFailuresAsExceptions, PostgresMixin):
Expand Down

0 comments on commit dc43dac

Please sign in to comment.