forked from dbt-labs/dbt-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_exceptions.py
35 lines (28 loc) · 1.17 KB
/
test_exceptions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import pytest
from dbt.exceptions import raise_duplicate_macro_name, CompilationException
from .utils import MockMacro
def test_raise_duplicate_macros_different_package():
macro_1 = MockMacro(package='dbt', name='some_macro')
macro_2 = MockMacro(package='dbt-myadapter', name='some_macro')
with pytest.raises(CompilationException) as exc:
raise_duplicate_macro_name(
node_1=macro_1,
node_2=macro_2,
namespace='dbt',
)
assert 'dbt-myadapter' in str(exc.value)
assert 'some_macro' in str(exc.value)
assert 'namespace "dbt"' in str(exc.value)
assert '("dbt" and "dbt-myadapter" are both in the "dbt" namespace)' in str(exc.value)
def test_raise_duplicate_macros_same_package():
macro_1 = MockMacro(package='dbt', name='some_macro')
macro_2 = MockMacro(package='dbt', name='some_macro')
with pytest.raises(CompilationException) as exc:
raise_duplicate_macro_name(
node_1=macro_1,
node_2=macro_2,
namespace='dbt',
)
assert 'some_macro' in str(exc.value)
assert 'namespace "dbt"' in str(exc.value)
assert "are both in" not in str(exc.value)