-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix for custom generic tests #211
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dave-connors-3 The code in this PR makes sense for the most part. I had one small question about the use of test/generic/
vs the test-path
value in dbt_project.yml
. Once that's sorted, we should be good to move forward.
dbt_meshify/dbt_projects.py
Outdated
if "tests/generic/" in macro.path: | ||
block_type = "test" | ||
name = macro.name[5:] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel super confident in using this hard-coded path. Would it make sense to use the test directory provided in dbt_project.yml
here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that makes sense to me! will update
@@ -140,7 +140,7 @@ def models(self) -> Dict[str, ModelNode]: | |||
return self._models | |||
|
|||
self._models = { | |||
node_name: node | |||
node_name: node # type: ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
|
||
blocks[unique_id] = JinjaBlock.from_file( | ||
path=self.path / macro.original_file_path, block_type="macro", name=macro.name | ||
path=self.path / macro.original_file_path, block_type=block_type, name=name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like that this function has been parameterized 👍🏻 🪨
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dave-connors-3 One minor question about the index
variable. Otherwise should be good to 🚢
top_level_folder in self.project.test_paths | ||
if self.project.test_paths | ||
else ["tests"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful logic 🪨
dbt_meshify/dbt_projects.py
Outdated
else ["tests"] | ||
): | ||
block_type = "test" | ||
index = len(top_level_folder) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is index
being used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah wait that's wrong -- the 5
should still be hardcoded to remove test_
from the name of the macro to properly search the jinja for my_test
and not test_my_test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! That makes sense 👍🏻
When someone creates a custom generic test, it gets rendered as a macro in the manifest. this means that when we compile all the macros in the project during startup of the group and split commands, we fail to find the correct test block.
this PR
JinjaBlock.from_file
call to betest
and trimstest_
(which dbt adds) to find the name of the custom generic test block when the macro path is undertests/generic/
submitted in partial fulfillment of #210