-
Notifications
You must be signed in to change notification settings - Fork 20
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
Enable macro unit tests #79
Enable macro unit tests #79
Conversation
Hi @mjirv , |
@LeopoldGabelmann thanks for submitting this! I think it's a great idea. I'm taking a closer look, but would you mind adding something to the README about this option so people know it exists? Thanks for adding tests btw. |
0405e14
to
d645685
Compare
d645685
to
315db53
Compare
Replaced the original code inside the test blocks with the new macros.
315db53
to
441f82e
Compare
This has to be done for the values and the keys. This is necessary so that the unit tests can be executed as macros.
441f82e
to
5d3b4e3
Compare
@mjirv - You're right, I should have added some explanation to the README on how to use this. I have done so now :) |
@mjirv friendly reminder :) |
* added incremental model and test * working code for incremental tests -- old unit test still works * working code for incremental tests -- old unit test still works * updated comments * moved unit test incremental to its own method * moved unit test incremental to its own method * updates readme and version for incremental tests * Enable macro unit tests (#79) * Added all existing unit tests in macro form. * Refactored the test blocks into macros blocks. Replaced the original code inside the test blocks with the new macros. * Adjusted the render logic for the the input mapping. This has to be done for the values and the keys. This is necessary so that the unit tests can be executed as macros. * Added explanations to the README on how to setup the tests as macros. --------- Co-authored-by: Leopold Gabelmann <[email protected]> * fixes merge issues * minor fixes * oops * thought i got rid of that already * o i see * adds exclude_columns * adds exclude_columns to test * bumps versions --------- Co-authored-by: Petter Söderlund <[email protected]> Co-authored-by: Leopold Gabelmann <[email protected]> Co-authored-by: Leopold Gabelmann <[email protected]>
{% macro __set_rendered_keys(ns, keys) %} | ||
{% for k in keys %} | ||
{% do ns.rendered_keys.update({k: render("{{ " + k + " }}")}) %} | ||
{% macro __set_rendered_mappings(ns, input_mapping) %} |
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.
FYI: This forces the ref in the sql
files and the yml
files to be EXACTLY the same
This is a:
Description & motivation
Within our team our yml for our dpt project got quite large. If one uses a lot of data tests, documents every column (even if it is centralized using docs) and then adds all the unit tests on top of it, it can be a lot of lines. Therefore, we were looking for a way to outsource all our unit tests inside of macros.
This has the additional benefit that it is very easy to run single a unit test while coding and controlling for possible errors. Furthermore, this makes it possible to run all data and unit tests apart from each other (e.g. in a CI/CD Pipeline) by selecting/excluding all unit tests via their folder path in tests.
Checklist