Skip to content

Tests that pin today's async network push and pull behavior #363

Description

@bjester

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, and active on the local transfer session.
  • The push test asserts that no Buffer rows remain for the transfer session.
  • The pull test asserts the local Store row 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, and PushPullClientTestCase in tests/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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions