Repository navigation
Description
Overview
This task (milestone M1) adds characterization tests for network syncs that use ASYNC_OPERATIONS. The tests record the exact HTTP requests and the final state of a push and a pull.
Background & Motivation
Milestones M2 to M4 refactor the sync layer. The refactors must not change what the network sync sends or stores. Today, no test pins the request sequence of a full sync, and the network operations have no direct unit tests.
These tests form the characterization suite. The refactor tasks must pass this suite without edits.
Design: spec. Plan: implementation plan, Task 2.
Description & Expected Outcomes
The tests run a real push and a real pull against the second-server test harness. A spy records each HTTP request that the client sends. For each request, the test records the method, the path, the body keys, and the requested transfer stage.
The tests compare the recorded list with a fixed expected list. Generated IDs are normalized, so the lists are stable between runs. The tests also assert the final local transfer session fields and the local data.
Deliverables & Contracts
The task delivers:
- A new test module
tests/testapp/tests/integration/test_network_characterization.py. - One test for a full push and one test for a full pull.
Acceptance Criteria
- The push test asserts the full request list, with every transfer stage present.
- The pull test asserts the full request list, with every transfer stage present.
- Both tests assert
records_total,records_transferred,transfer_stage,transfer_stage_status, andactiveon the local transfer session. - The push test asserts that no
Bufferrows remain for the transfer session. - The pull test asserts the local
Storerow count for the filter. - Both tests pass against the current code, with no changes to production code.
Technical Pointers & Architecture
- Target Components:
morango/sync/session.py(SessionWrapper.request),morango/sync/syncsession.py(NetworkSyncConnection,TransferClient). - Related Patterns:
LiveServer,second_environment, andPushPullClientTestCaseintests/testapp/tests/integration/test_syncsession.py:56-219. - Data Model & Schema Considerations: None.
- Resilience & Failure Modes: The spy must pass each call through to the real method, so that retries and errors behave as today.
Notes & Tradeoffs
- Dependencies: Blocked by: none. Blocks: Tests that pin today's legacy network sync behavior #364.
- Testing Requirements: After this task and Tests that pin today's legacy network sync behavior #364 merge, nobody edits this test module until milestone M4 is complete.
- Tradeoffs & Alternatives Considered: A fake HTTP server gives faster tests. The real second server gives stronger evidence, and the harness already exists.
Metadata
- Complexity: Medium
- Target Branch: release-v0.9.x
AI Usage
Drafted with Claude (Claude Code) from the approved design spec and implementation plan. The author reviewed the requirements, and the code references were checked against the release-v0.9.x codebase.
Activity
Extract the live server sync harness into helpers
Add characterization tests for async network sync
Extract the live server sync harness into helpers
Add characterization tests for async network sync
Add characterization tests for async and legacy network sync (learnin…