test: add unit testings for core functions of sanity module#223
Merged
Conversation
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive unit tests for the sanity module, covering core functionality for dataset validation including context management, rule organization, result evaluation, and sanity check execution.
Key changes:
- Added tests for sanity context initialization and data discovery from filesystem paths
- Added tests for rule group mapping logic and result evaluation under different strictness modes
- Added end-to-end test for the main sanity check function
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/sanity/test_sanity_run.py | Tests the main sanity_check function with strict and non-strict modes |
| tests/sanity/test_sanity_result.py | Tests report creation functions and SanityResult.is_passed logic under different scenarios |
| tests/sanity/test_sanity_registry.py | Tests RuleGroup.to_group mapping for valid and invalid rule IDs |
| tests/sanity/test_sanity_context.py | Tests SanityContext.from_path for correct identification of data root, directories, and schema files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified FilesNo covered modified files...
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This pull request adds a set of new tests for the
sanitymodule, improving coverage for key components such as context management, rule group mapping, result evaluation, and the main sanity check function. These tests help ensure that the core logic for dataset structure validation and reporting behaves as expected under different scenarios.New test coverage and validation:
Sanity context and data discovery:
test_sanity_contextto verify thatSanityContext.from_pathcorrectly identifies data root, dataset ID, and subdirectories, and maps schema files as expected.Rule group mapping:
test_rule_group_to_groupto ensure thatRuleGroup.to_groupmaps rule IDs to their correct groups and handles invalid IDs gracefully.Result reporting and evaluation:
test_make_reportandtest_make_skippedto validate the creation ofReportobjects and their status assignment based on reasons and severity.test_sanity_resultto check the logic ofSanityResult.is_passedunder both strict and non-strict modes, ensuring correct pass/fail evaluation depending on report severities and statuses.Sanity check execution:
test_sanity_checkto test the end-to-end execution of thesanity_checkfunction, verifying the overall result under different strictness settings.