test: add comprehensive unit tests for core utilities#990
Merged
qin-ctx merged 1 commit intovolcengine:mainfrom Mar 26, 2026
Merged
test: add comprehensive unit tests for core utilities#990qin-ctx merged 1 commit intovolcengine:mainfrom
qin-ctx merged 1 commit intovolcengine:mainfrom
Conversation
Add comprehensive unit tests for the following modules: - openviking/utils/circuit_breaker.py: Test CircuitBreaker class and classify_api_error function - openviking/utils/process_lock.py: Test acquire_data_dir_lock and related functions - openviking/utils/time_utils.py: Test parse_iso_datetime, format_iso8601, format_simplified, get_current_timestamp - openviking/core/context.py: Test Context class and related enums - openviking/message: Test Message, TextPart, ContextPart, ToolPart classes Test coverage includes: - Normal functionality tests - Edge case handling - Error handling - Unicode and special character handling - Thread safety (for circuit breaker) - Round-trip serialization/deserialization Total: 212 test cases added
|
Failed to generate code suggestions for PR |
qin-ctx
approved these changes
Mar 26, 2026
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.
Summary
This PR adds comprehensive unit tests for core OpenViking utility modules to improve test coverage and code reliability.
Changes
New Test Files
tests/unit/test_circuit_breaker.py (93 tests)
TestClassifyApiError: Tests for API error classification (permanent vs transient)TestCircuitBreaker: Tests for circuit breaker state transitions (CLOSED, OPEN, HALF_OPEN)TestCircuitBreakerEdgeCases: Edge cases including thread safetytests/unit/test_process_lock.py (36 tests)
TestReadPidFile: Tests for PID file readingTestIsPidAlive: Tests for process liveness detectionTestAcquireDataDirLock: Tests for data directory lock acquisitionTestAcquireDataDirLockEdgeCases: Edge cases for lock handlingtests/unit/test_time_utils_comprehensive.py (41 tests)
TestParseIsoDatetime: Tests for ISO datetime parsingTestFormatIso8601: Tests for ISO 8601 formattingTestFormatSimplified: Tests for simplified time formattingTestGetCurrentTimestamp: Tests for timestamp generationTestTimeUtilsRoundTrip: Round-trip conversion teststests/unit/test_context.py (66 tests)
TestResourceContentType,TestContextType,TestContextLevel: Enum testsTestContextInit: Initialization testsTestContextDeriveContextType,TestContextDeriveCategory: Derivation testsTestContextMethods: Method testsTestContextToDict,TestContextFromDict: Serialization testsTestContextWithUser: User-related teststests/unit/test_message.py (56 tests)
TestTextPart,TestContextPart,TestToolPart: Part class testsTestPartFromDict: Part deserialization testsTestMessageInit,TestMessageContent: Message initialization testsTestMessageToDict,TestMessageFromDict: Serialization testsTestMessageFactoryMethods: Factory method testsTestMessageMethods: Method testsTestMessageEdgeCases: Edge case handlingTest Coverage
Test Results
All 212 tests pass:
Code Quality
ruff check)ruff formatRelated Issues
Improves test coverage for core utility modules that are used throughout the OpenViking SDK.