mirror of
https://github.com/Sea-Haven-Industries/open-swe.git
synced 2026-09-30 10:23:14 +00:00
Applies the plan's C5 step: git mv every test per the domain-reorg
move-map (movemap-m50.txt) into tests/{agent,analyzer,auth,dashboard,
github,middleware,models,reviewer,sandbox,slack,tools,webhooks}/, plus
the 13 fork-only placements from the scoping report §2c (Atlassian
webhook tests -> tests/webhooks/, test_atlassian_connect.py and
test_auth_error_leak.py -> tests/auth/, jira/confluence util tests ->
tests/tools/, test_repo_binding_isolation.py -> tests/sandbox/,
bot-identity/autofix tests -> tests/github/).
Path-only move: the only content edits are parents[1] -> parents[2]
fixes in test_e2b_integration.py and test_daytona_integration.py,
required because their __file__-relative ROOT path gained one more
directory level in the move.
Monkeypatch retargets for these files were already completed in C4;
none remained outstanding here.
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
"""Unit tests for per-PR auto-fix opt-out state."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
from unittest.mock import AsyncMock, MagicMock, patch
|
|
|
|
import pytest
|
|
|
|
from agent.dashboard import autofix_state
|
|
|
|
|
|
@pytest.mark.asyncio
|
|
async def test_set_and_check_pr_disabled() -> None:
|
|
store: dict[tuple[Any, ...], Any] = {}
|
|
client = MagicMock()
|
|
|
|
async def put_item(ns: list[str], key: str, value: dict[str, Any]) -> None:
|
|
store[(tuple(ns), key)] = value
|
|
|
|
async def get_item(ns: list[str], key: str) -> dict[str, Any] | None:
|
|
value = store.get((tuple(ns), key))
|
|
return {"value": value} if value is not None else None
|
|
|
|
client.store.put_item = AsyncMock(side_effect=put_item)
|
|
client.store.get_item = AsyncMock(side_effect=get_item)
|
|
|
|
with patch.object(autofix_state, "get_client", return_value=client):
|
|
assert await autofix_state.is_pr_autofix_disabled("O", "R", 5) is False
|
|
await autofix_state.set_pr_autofix_disabled("O", "R", 5, True)
|
|
assert await autofix_state.is_pr_autofix_disabled("o", "r", 5) is True
|
|
await autofix_state.set_pr_autofix_disabled("o", "r", 5, False)
|
|
assert await autofix_state.is_pr_autofix_disabled("o", "r", 5) is False
|