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

convert to use unit test name at top level key #8966

Merged
merged 12 commits into from
Nov 3, 2023

Conversation

emmyoop
Copy link
Member

@emmyoop emmyoop commented Nov 1, 2023

resolves #8698

  • this is only half what the above issue wants. renaming top level key from unit to unit-tests will be a separate PR

Problem

Uses test name instead of model as top level key, resulting in the removal of test suites under a single key.

Solution

  • Use name as top level key
  • remove logic for test suite
  • also update unique key to match other node type patterns

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX
  • This PR includes type annotations for new and modified functions

@cla-bot cla-bot bot added the cla:yes label Nov 1, 2023
Copy link
Contributor

github-actions bot commented Nov 1, 2023

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

Copy link

codecov bot commented Nov 1, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (02a3dc5) 86.63% compared to head (75a4747) 86.63%.

Additional details and impacted files
@@                       Coverage Diff                       @@
##           unit_testing_feature_branch    #8966      +/-   ##
===============================================================
- Coverage                        86.63%   86.63%   -0.01%     
===============================================================
  Files                              181      181              
  Lines                            26979    26970       -9     
===============================================================
- Hits                             23374    23365       -9     
  Misses                            3605     3605              
Flag Coverage Δ
integration 83.50% <100.00%> (-0.01%) ⬇️
unit 64.65% <80.00%> (-0.01%) ⬇️

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

Files Coverage Δ
core/dbt/contracts/graph/unparsed.py 94.30% <100.00%> (-0.03%) ⬇️
core/dbt/parser/partial.py 93.71% <100.00%> (-0.02%) ⬇️
core/dbt/parser/unit_tests.py 93.45% <100.00%> (-0.07%) ⬇️
core/dbt/task/unit_test.py 95.57% <ø> (ø)

... and 1 file with indirect coverage changes

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

@emmyoop emmyoop force-pushed the er/8698-unit-test-name branch 2 times, most recently from 97ee053 to 1d3d86f Compare November 2, 2023 15:40
@emmyoop emmyoop changed the title [WIP] use unit test name as top level convert to use unit test name at top level key Nov 2, 2023
)
self.manifest.add_unit_test(self.yaml.file, unit_test_definition)
unit_test_case_unique_id = (
f"{NodeType.Unit}.{self.project.project_name}.{unit_test.model}.{unit_test.name}"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason we were hard coding unit here? It doesn't match how we assign the unique ids for other node types.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there's an explicit reason. What would be a more conventional way to build the unique_id here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using {NodeType.Unit} instead of a hardcoded unit is more conventional. I went ahead and made the change because it didn't seem intentional but wanted to check in case.

@emmyoop emmyoop marked this pull request as ready for review November 2, 2023 16:24
@emmyoop emmyoop requested a review from a team as a code owner November 2, 2023 16:24
@emmyoop emmyoop requested review from QMalcolm, gshank and MichelleArk and removed request for QMalcolm November 2, 2023 16:24
@emmyoop emmyoop added the Skip Changelog Skips GHA to check for changelog file label Nov 2, 2023
@@ -711,7 +711,6 @@ def _handle_element_change(
# Take a "section" of the schema file yaml dictionary from saved and new schema files
# and determine which parts have changed
def get_diff_for(self, key, saved_yaml_dict, new_yaml_dict):
dict_name = "model" if key == "unit" else "name"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@emmyoop emmyoop merged commit f629baa into unit_testing_feature_branch Nov 3, 2023
49 checks passed
@emmyoop emmyoop deleted the er/8698-unit-test-name branch November 3, 2023 18:59
gshank added a commit that referenced this pull request Jan 16, 2024
* Initial implementation of unit testing (from pr #2911)

Co-authored-by: Michelle Ark <michelle.ark@dbtlabs.com>

* 8295 unit testing artifacts (#8477)

* unit test config: tags & meta (#8565)

* Add additional functional test for unit testing selection, artifacts, etc (#8639)

* Enable inline csv format in unit testing (#8743)

* Support unit testing incremental models (#8891)

* update unit test key: unit -> unit-tests (#8988)


* convert to use unit test name at top level key (#8966)

* csv file fixtures (#9044)

* Unit test support for `state:modified` and `--defer` (#9032)

Co-authored-by: Michelle Ark <michelle.ark@dbtlabs.com>

* Allow use of sources as unit testing inputs (#9059)

* Use daff for diff formatting in unit testing (#8984)

* Fix #8652: Use seed file from disk for unit testing if rows not specified in YAML config (#9064)

Co-authored-by: Michelle Ark <MichelleArk@users.noreply.github.com>
Fix #8652: Use seed value if rows not specified

* Move unit testing to test and build commands (#9108)

* Enable unit testing in non-root packages (#9184)

* convert test to data_test (#9201)

* Make fixtures files full-fledged members of manifest and enable partial parsing (#9225)

* In build command run unit tests before models (#9273)

---------

Co-authored-by: Michelle Ark <michelle.ark@dbtlabs.com>
Co-authored-by: Michelle Ark <MichelleArk@users.noreply.github.com>
Co-authored-by: Emily Rockman <emily.rockman@dbtlabs.com>
Co-authored-by: Jeremy Cohen <jeremy@dbtlabs.com>
Co-authored-by: Kshitij Aranke <kshitij.aranke@dbtlabs.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes Skip Changelog Skips GHA to check for changelog file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants