Skip to content

Commit

Permalink
add a unit test for raising the correct exception
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare committed Sep 5, 2024
1 parent 9eca0d2 commit 9f07b2b
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/unit/test_behavior_flags.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import pytest

from dbt_common.behavior_flags import Behavior
from dbt_common.exceptions.base import CompilationError


def test_behavior_default():
Expand Down Expand Up @@ -40,6 +43,19 @@ def test_behavior_user_override():
assert behavior.flag_default_true_override_true.setting is True


def test_behavior_unregistered_flag_raises_correct_exception():
behavior = Behavior(
[
{"name": "behavior_flag_exists", "default": False},
],
{},
)

assert behavior.behavior_flag_exists.setting is False
with pytest.raises(CompilationError):
assert behavior.behavior_flag_does_not_exist


def test_behavior_flag_can_be_used_as_conditional():
behavior = Behavior(
[
Expand Down

0 comments on commit 9f07b2b

Please sign in to comment.