From f1deecc623cf5587bd4daeb831f2d57e7fbad8db Mon Sep 17 00:00:00 2001 From: Jeremy Cohen Date: Mon, 25 Oct 2021 19:47:46 +0200 Subject: [PATCH] Prefer root namespace by default (#31) --- tests/unit/test_context.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tests/unit/test_context.py b/tests/unit/test_context.py index 12f250b71..316c32fd6 100644 --- a/tests/unit/test_context.py +++ b/tests/unit/test_context.py @@ -452,14 +452,19 @@ def test_resolve_specific(config, manifest_extended, redshift_adapter, get_inclu with pytest.raises(dbt.exceptions.CompilationException): ctx['adapter'].dispatch('macro_a').macro + # root namespace is always preferred, unless search order is explicitly defined in 'dispatch' config assert ctx['adapter'].dispatch('some_macro').macro is package_rs_macro - assert ctx['adapter'].dispatch('some_macro', 'dbt').macro is rs_macro + assert ctx['adapter'].dispatch('some_macro', 'dbt').macro is package_rs_macro assert ctx['adapter'].dispatch('some_macro', 'root').macro is package_rs_macro - # override 'dbt' namespace, dispatch to 'root' first + # override 'dbt' namespace search order, dispatch to 'root' first ctx['adapter'].config.dispatch = [{'macro_namespace': 'dbt', 'search_order': ['root', 'dbt']}] assert ctx['adapter'].dispatch('some_macro', macro_namespace = 'dbt').macro is package_rs_macro - # override 'root' namespace, dispatch to 'dbt' first + # override 'dbt' namespace search order, dispatch to 'dbt' only + ctx['adapter'].config.dispatch = [{'macro_namespace': 'dbt', 'search_order': ['dbt']}] + assert ctx['adapter'].dispatch('some_macro', macro_namespace = 'dbt').macro is rs_macro + + # override 'root' namespace search order, dispatch to 'dbt' first ctx['adapter'].config.dispatch = [{'macro_namespace': 'root', 'search_order': ['dbt', 'root']}] - assert ctx['adapter'].dispatch('some_macro', macro_namespace='root').macro is rs_macro + assert ctx['adapter'].dispatch('some_macro', macro_namespace = 'root').macro is rs_macro