Skip to content
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

[Backport 1.8.latest] Stop mis-identifying unit_test config paths in dbt_project.yaml as unused #10314

Merged
merged 5 commits into from
Jun 17, 2024

Conversation

QMalcolm
Copy link
Contributor

This is a manual backport of #10312 to 1.8.latest. This backport was done by cherry-picking the commits from the original branch, qmalcolm--10311-stop-mis-identifying-unit-test-config-paths-as-unused, instead of from the squash commit from main. Specifically I:

  1. ran git cherry-pick 58990aa~..ffd1272
  2. managed merge conflicts and made adjustments to handle not existent fixtures (by commit)

QMalcolm added 5 commits June 14, 2024 10:01
We're doing this in preperation to a for a unit test which will be testing
these nodes (as well as others) and thus we want them in the manifest.
NOTE: This was cherry-picked, and interestingly this specific commit, isn't
entirely necessary. That is because the test this commit wasn't migrated
to the new pytest `manifest` fixture when the `1.8.latest` branch was made.
However, for the sake of simplicity, we're not dropping it from the range of
commits we're cherry-picking because doing so creates extra confusion

In the previous commit, 58990aa, we added
the `saved_query` fixture to the `manifest` fixture. This broke the test
`tests/unit/parser/test_manifest.py::TestPartialParse::test_partial_parse_by_version`.
It broke because the `Manifest.deepcopy` manifest basically dictifies things. When we were
dictifying the `QueryParams` of the `saved_query` before, the `where` key was getting
dropped because it was `None`. We'd then run into a runtime error on instantiation of the
`QueryParams` because although `where` is declared as _optional_, we don't set a default
value for it. And thus, kaboom :(

We should probably provide a default value for `where`. However that is out of scope
for this branch of work.
In 58990aa we added a semantic model
to the `manifest` fixture. This broke the test
`tests/unit/graph/test_selector_methods.py::test_select_fqn` because in
the test it selects nodes based on the string `*.*.*_model`. The newly
added semantic model matches this, and thus needed to be added to the
expected results.
Note: At this point the test when run with for a `unit_test` config
taht should be considered used, fails. This is because it is not being
properly identified as used.
Because `unit_tests` weren't being included in calls to `Manifest.get_resource.fqns`,
it always appeared to `_warn_for_unused_resource_config_paths` that there were no
unit tests in the manifest. Because of this `_warn_for_unused_resource_config_paths` thought
that _any_ `unit_test` config in `dbt_project.yaml` was unused.
@QMalcolm QMalcolm requested a review from a team as a code owner June 14, 2024 20:34
@cla-bot cla-bot bot added the cla:yes label Jun 14, 2024
Copy link

codecov bot commented Jun 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.30%. Comparing base (20eecad) to head (737da21).

Additional details and impacted files
@@             Coverage Diff             @@
##           1.8.latest   #10314   +/-   ##
===========================================
  Coverage       88.30%   88.30%           
===========================================
  Files             181      181           
  Lines           22758    22758           
===========================================
  Hits            20097    20097           
  Misses           2661     2661           
Flag Coverage Δ
integration 85.55% <ø> (-0.02%) ⬇️
unit 62.80% <ø> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@QMalcolm QMalcolm merged commit 341d025 into 1.8.latest Jun 17, 2024
123 checks passed
@QMalcolm QMalcolm deleted the manual-backport--10312-to-1.8.latest branch June 17, 2024 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants