Skip to content

Commit 1c26b1a

Browse files
committed
test fixes
1 parent 4271d1f commit 1c26b1a

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

integration_tests/tests/test_dbt_artifacts/test_microbatch_compiled_code.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@ def _run_microbatch_model_and_get_latest_success_result(
5353

5454

5555
@contextmanager
56-
def _with_microbatch_override_macro(dbt_project: DbtProject):
56+
def _with_microbatch_macro_file(dbt_project: DbtProject, macro_name: str):
5757
macro_path = (
5858
dbt_project.project_dir_path / "macros" / "microbatch.sql"
5959
)
60-
macro_sql = """{% macro get_incremental_microbatch_sql(arg_dict) %}
60+
macro_sql = f"""{{% macro {macro_name}(arg_dict) %}}
6161
{{ return(elementary.get_incremental_microbatch_sql(arg_dict)) }}
62-
{% endmacro %}
62+
{{% endmacro %}}
6363
"""
6464
if macro_path.exists():
6565
raise FileExistsError(f"Expected no macro file at {macro_path}")
@@ -77,7 +77,7 @@ def _with_microbatch_override_macro(dbt_project: DbtProject):
7777
def test_microbatch_run_results_has_compiled_code(test_id: str, dbt_project: DbtProject):
7878
dbt_project.dbt_runner.vars["disable_run_results"] = False
7979

80-
with _with_microbatch_override_macro(dbt_project):
80+
with _with_microbatch_macro_file(dbt_project, "get_incremental_microbatch_sql"):
8181
run_results = _run_microbatch_model_and_get_latest_success_result(
8282
dbt_project, test_id
8383
)
@@ -94,7 +94,12 @@ def test_microbatch_run_results_without_override_has_empty_compiled_code(
9494
):
9595
dbt_project.dbt_runner.vars["disable_run_results"] = False
9696

97-
run_results = _run_microbatch_model_and_get_latest_success_result(dbt_project, test_id)
97+
with _with_microbatch_macro_file(
98+
dbt_project, "get_incremental_microbatch_sql_not_used"
99+
):
100+
run_results = _run_microbatch_model_and_get_latest_success_result(
101+
dbt_project, test_id
102+
)
98103
assert run_results, "Expected a successful run result row for microbatch model"
99104
assert not run_results[0]["compiled_code"], (
100105
"Expected compiled_code to stay empty when microbatch override macro is absent"

0 commit comments

Comments
 (0)