Add tests for package_search (#2092) - #2149
Conversation
Signed-off-by: Ahlbertng <70105688+ahlbertng@users.noreply.github.com>
Signed-off-by: Ahlbertng <70105688+ahlbertng@users.noreply.github.com>
c11bd7b to
26ef581
Compare
Signed-off-by: Ahlbertng <70105688+ahlbertng@users.noreply.github.com>
Signed-off-by: Ahlbertng <70105688+ahlbertng@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2149 +/- ##
==========================================
+ Coverage 61.31% 61.72% +0.41%
==========================================
Files 164 164
Lines 20568 20568
Branches 3575 3575
==========================================
+ Hits 12611 12696 +85
+ Misses 7085 6983 -102
- Partials 872 889 +17 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Thank you for the submission of this new set of tests. We really appreciate any added coverage we can squeeze into the repo at this point, especially for such un-tested areas.
I've issued some specific comments attached to areas near the code that they pertain to. These are the main comments I'm making that would flip my recommendation from "don't merge" to "do merge". I made some specific line comments, but the real issue is that the current flake8 linter job fails, so just address those items.
I would express that the largest useful gaps to continue covering, whether they are a part of this PR, or you or anyone else tackles with additional work, would be these:
(Please comment, if you intend to go further with the coverage and aim to address these as well, or if you want to keep this PR self-contained just to the current change-set)
test the validate=True path. The ResourceSearcher.search() method has a substantial validate code path with error handling for ResourceContentError. No tests exercise this yet, and is arguably the most complex portion of the module.
test for glob patterns. ResourceSearcher.search() uses fnmatch.fnmatch on the name pattern. A test like searcher.search("py*") would verify the glob codepaths, which is a core feature of the searcher.
test for family resource type. When no version range is specified and multiple families match, the searcher returns resource_type="family". The current tests only exercise the package resource type.
Signed-off-by: Ahlbertng <70105688+ahlbertng@users.noreply.github.com>
Signed-off-by: Ahlbertng <70105688+ahlbertng@users.noreply.github.com>
Signed-off-by: Ahlbertng <70105688+ahlbertng@users.noreply.github.com>
Description
This PR adds unit tests for
src/rez/package_search.py, which currently has no test coverage (as noted in #2092).Addresses part of #2092.
What's tested
get_reverse_dependency_tree()Correctly builds a reverse dependency tree for a package with known direct dependents
Respects the
depthargument (e.g.depth=0returns only the root package)ResourceSearcher.search()Finds all versions of a package family
Returns only the latest version when
latest=TrueResourceSearchResultFormatterDefault (no
output_format) output correctly shows a package's qualified nameResourceSearchResultCorrectly stores
resource,resource_type, andvalidation_error(including defaultNone)Notes
Tests reuse the existing
solver/packagestest data already used bytest_packages.py, so no new test fixtures were added.get_plugins()is not yet covered, no existing test data currently includes packages withplugin_forset. Open to guidance on whether to add new fixture packages for this, or if there's a preferred approach.