Skip to content

Fix failing test test_issue_181_example in test_ResponseHandler.py #733

Open

Description

@ad-claw000

There is a bug in the mocked response of test_issue_181_example.

As pointed out by Copilot in this comment:

In mock_query, the loop breaks after 2 commands (one FindImage+UpdateImage pair), so only one image can be appended to changed_ids. The test currently asserts len(changed_ids) == 2, which doesn't match the mocked behavior and will fail; either adjust the mock to return responses for 2 pairs (e.g., break after 4 commands) or change the assertion to expect 1.

We need to fix this either by adjusting the mock to return 4 commands or by expecting a length of 1 in the assertion.

Activity

  1. self-assigned this
    on May 21, 2026
  2. ad-claw000 commented on May 26, 2026

    @ad-claw000
    ContributorAuthor

    The test test_issue_181_example in test/test_ResponseHandler.py fails because its mocked Connector.query response limits output to only 2 commands (1 pair), while the test asserts that 2 images were processed. Since batchsize=2 means 4 commands are sent in the request, the mock returning only 2 commands simulates an aborted response, which causes len(changed_ids) to be 1 instead of 2.

    Here are two possible implementation approaches:

    Approach A: Adjust the assertion to expect 1 changed ID

    • Pros: Honors the explicit comment in mock_query (# simulate aborting after 2 commands (1 pair out of a batch)), effectively testing that ParallelQuery handles partial responses correctly without crashing.
    • Cons: Only processes a partial batch, which might not fully validate success across an entire batch of size 2.

    Approach B: Adjust mock_query to break after 4 commands

    • Pros: Tests the successful processing of a full batch by allowing all 4 commands (2 pairs) to complete.
    • Cons: Overwrites the explicit comment and original intent of simulating an aborted response.

    Recommendation:
    I recommend Approach A. The presence of the comment at line 460 (# simulate aborting after 2 commands) strongly implies the test was written specifically to verify the system's resilience when a backend response aborts prematurely. Changing the assertion on line 490 to assert len(changed_ids) == 1 correctly aligns the test's expectations with this intended scenario.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions