Skip to content

Commit

Permalink
Patch assertion in TestStoreTestFailuresAsExceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
morsapaes committed Nov 20, 2023
1 parent 7a2ac7e commit aaab048
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions misc/dbt-materialize/tests/adapter/test_store_test_failures.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,22 @@

import pytest
from dbt.contracts.results import TestStatus
from dbt.tests.adapter.store_test_failures_tests import basic
from dbt.tests.adapter.store_test_failures_tests.basic import (
StoreTestFailuresAsInteractions,
)
from dbt.tests.adapter.store_test_failures_tests.fixtures import (
models__file_model_but_with_a_no_good_very_long_name,
models__fine_model,
)
from dbt.tests.adapter.store_test_failures_tests.test_store_test_failures import (
StoreTestFailuresAsBase,
StoreTestFailuresAsExceptions,
StoreTestFailuresAsGeneric,
StoreTestFailuresAsProjectLevelEphemeral,
StoreTestFailuresAsProjectLevelOff,
StoreTestFailuresAsProjectLevelView,
StoreTestFailuresBase,
TestResult,
)
from dbt.tests.util import run_dbt

Expand Down Expand Up @@ -62,44 +71,42 @@ class TestMaterializeStoreTestFailures(TestStoreTestFailures):
pass


class TestStoreTestFailuresAsInteractions(basic.StoreTestFailuresAsInteractions):
class TestStoreTestFailuresAsInteractions(StoreTestFailuresAsInteractions):
pass


class TestStoreTestFailuresAsProjectLevelOff(basic.StoreTestFailuresAsProjectLevelOff):
class TestStoreTestFailuresAsProjectLevelOff(StoreTestFailuresAsProjectLevelOff):
pass


class TestStoreTestFailuresAsProjectLevelView(
basic.StoreTestFailuresAsProjectLevelView
):
class TestStoreTestFailuresAsProjectLevelView(StoreTestFailuresAsProjectLevelView):
pass


class TestStoreTestFailuresAsGeneric(basic.StoreTestFailuresAsGeneric):
class TestStoreTestFailuresAsGeneric(StoreTestFailuresAsGeneric):
pass


class TestStoreTestFailuresAsProjectLevelEphemeral(
basic.StoreTestFailuresAsProjectLevelEphemeral
StoreTestFailuresAsProjectLevelEphemeral
):
pass


class TestStoreTestFailuresAsExceptions(basic.StoreTestFailuresAsExceptions):
class TestStoreTestFailuresAsExceptions(StoreTestFailuresAsExceptions):
def test_tests_run_unsuccessfully_and_raise_appropriate_exception(self, project):
results = run_dbt(["test"], expect_pass=False)
assert len(results) == 1
result = results[0]
assert "Compilation Error" in result.message
assert "'error' is not a valid value" in result.message
assert (
"Accepted values are: ['table', 'view', 'materialized_view']"
"Accepted values are: ['ephemeral', 'table', 'view', 'materialized_view']"
in result.message
)


class TestStoreTestFailuresAsProjectLevelMaterializeView(basic.StoreTestFailuresAsBase):
class TestStoreTestFailuresAsProjectLevelMaterializeView(StoreTestFailuresAsBase):
"""
These scenarios test that `store_failures_as` at the project level takes precedence over `store_failures`
at the model level.
Expand Down Expand Up @@ -128,8 +135,8 @@ def project_config_update(self):

def test_tests_run_successfully_and_are_stored_as_expected(self, project):
expected_results = {
basic.TestResult("results_true", TestStatus.Fail, "materialized_view"),
basic.TestResult("results_false", TestStatus.Fail, "materialized_view"),
basic.TestResult("results_unset", TestStatus.Fail, "materialized_view"),
TestResult("results_true", TestStatus.Fail, "materialized_view"),
TestResult("results_false", TestStatus.Fail, "materialized_view"),
TestResult("results_unset", TestStatus.Fail, "materialized_view"),
}
self.run_and_assert(project, expected_results)

0 comments on commit aaab048

Please sign in to comment.