Skip to content

Commit

Permalink
Fix post_model_hook in data and unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Oct 2, 2024
1 parent 7940ad5 commit 16562c6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/dbt/task/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,15 @@ def execute_data_test(self, data_test: TestNode, manifest: Manifest) -> TestResu
"Invalid materialization context generated, missing config: {}".format(context)
)

context_config = context["config"]

Check warning on line 162 in core/dbt/task/test.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/task/test.py#L162

Added line #L162 was not covered by tests

# generate materialization macro
macro_func = MacroGenerator(materialization_macro, context)
try:
# execute materialization macro
macro_func()
finally:
self.adapter.post_model_hook(context, hook_ctx)
self.adapter.post_model_hook(context_config, hook_ctx)

Check warning on line 170 in core/dbt/task/test.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/task/test.py#L170

Added line #L170 was not covered by tests

# load results from context
# could eventually be returned directly by materialization
Expand Down Expand Up @@ -238,6 +240,8 @@ def execute_unit_test(
"Invalid materialization context generated, missing config: {}".format(context)
)

context_config = context["config"]

Check warning on line 243 in core/dbt/task/test.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/task/test.py#L243

Added line #L243 was not covered by tests

# generate materialization macro
macro_func = MacroGenerator(materialization_macro, context)
try:
Expand All @@ -249,7 +253,7 @@ def execute_unit_test(
f"There may be an error in the unit test definition: check the data types.\n {e}"
)
finally:
self.adapter.post_model_hook(context, hook_ctx)
self.adapter.post_model_hook(context_config, hook_ctx)

Check warning on line 256 in core/dbt/task/test.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/task/test.py#L256

Added line #L256 was not covered by tests

# load results from context
# could eventually be returned directly by materialization
Expand Down

0 comments on commit 16562c6

Please sign in to comment.