tests: add unit tests for query type functions in schemas.py#281
Open
Nikitaa104 wants to merge 1 commit intojenkinsci:mainfrom
Open
tests: add unit tests for query type functions in schemas.py#281Nikitaa104 wants to merge 1 commit intojenkinsci:mainfrom
Nikitaa104 wants to merge 1 commit intojenkinsci:mainfrom
Conversation
- test is_valid_query_type() for valid, invalid, empty, and case-sensitive inputs - test str_to_query_type() for correct conversion and ValueError on invalid input - test try_str_to_query_type() for fallback to MULTI and warning log on invalid input Closes jenkinsci#277
Contributor
Author
|
Hi @berviantoleo, I've added 14 unit tests for the query type utility functions in schemas.py which had zero coverage. All tests pass locally: |
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 PR does
Adds unit tests for the three query type utility functions in
api/models/schemas.pywhich had zero test coverage.Functions Tested
is_valid_query_type()—validates if a string is a valid QueryType memberstr_to_query_type()—converts string to QueryType enumtry_str_to_query_type()—safe conversion with fallback to MULTITest Cases Added (14 total)
is_valid_query_type()returns True for SIMPLE and MULTIis_valid_query_type()returns False for invalid and empty stringsis_valid_query_type()is case sensitivestr_to_query_type()correctly converts SIMPLE and MULTIstr_to_query_type()raises ValueError for invalid and empty inputtry_str_to_query_type()returns correct QueryType for valid inputtry_str_to_query_type()falls back to MULTI for invalid inputtry_str_to_query_type()logs warning on invalid inputtry_str_to_query_type()falls back to MULTI for empty stringLocal Test Results
14 passed, 4 warnings in 0.22s
Closes #277