Conversation
… get_vessel error paths Fills four coverage gaps in unit_test.py: - subscribe_ais_stream(): batch processing, dedup counter, acks, WS broadcast, catchup detection, error handling, batch-size selection - Database._load_position_cache: non-empty DB reconnect, first_seen preservation, empty-table baseline - cleanup_old_positions: multi-batch loop continuation and partial-batch exit - get_vessel: invalid/missing first_seen_at_location error branches Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2 tasks
The test was using a hardcoded timestamp from 2024-03-01 which is well outside the 7-day retention window, causing the position to be deleted and the assertion to fail. Replace with datetime.now() so the timestamp is always within the retention window. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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
TestSubscribeAisStreamUnitclass tounit_test.pycoveringsubscribe_ais_stream()— the service's core NATS loop — with 14 new tests for batch processing, deduplication counter, ack-after-commit, WebSocket broadcast, catchup detection, error recovery, and batch-size selectionTestDatabaseLoadPositionCacheNonEmptywith 3 tests for_load_position_cache()against a pre-populated DB, including reconnect cache rebuild andfirst_seen_at_locationpreservationTestDatabaseCleanupOldPositionsMultiBatchwith 4 tests exercising thewhile Truebatch-delete loop continuation path incleanup_old_positions()TestGetVesselErrorBrancheswith 4 tests coveringget_vessel()analytics error paths: missing vessel, validfirst_seen, malformedfirst_seen(ValueError branch), and NULLfirst_seen(no time fields added)Test plan
//projects/ships/backend/tests:unit_testprojects/ships/backend/tests/unit_test.pychanged🤖 Generated with Claude Code