test: isolate Star invitation state and stabilize late-result waits (#6076)
* test: isolate Star invitation state and relax late-result deadline * test: keep invitation fixtures outside test workspaces
This commit is contained in:
1 parent
07c4e3f0d1
commit
42f06ab1dc
4 files changed
+20
-10
No files matched your search
@@ -57,6 +57,15 @@ def _isolate_sessions_root(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> I
|
|||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(autouse=True)
|
||||||
|
def _isolate_star_prompt_store(
|
||||||
|
tmp_path_factory: pytest.TempPathFactory, monkeypatch: pytest.MonkeyPatch
|
||||||
|
) -> None:
|
||||||
|
"""Keep WebUI completion events out of the user's invitation state and lock."""
|
||||||
|
webui_dir = tmp_path_factory.mktemp("star-prompt-webui")
|
||||||
|
monkeypatch.setattr("nanobot.webui.star_prompt.get_webui_dir", lambda: webui_dir)
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(autouse=True)
|
@pytest.fixture(autouse=True)
|
||||||
def _isolate_pairing_store(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
def _isolate_pairing_store(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||||
"""Keep channel pairing tests out of the user's active pairing store."""
|
"""Keep channel pairing tests out of the user's active pairing store."""
|
||||||
|
|||||||
@@ -4208,13 +4208,11 @@ def test_bootstrap_secret_also_enforced_on_localhost(bus: MagicMock) -> None:
|
|||||||
|
|
||||||
@pytest.mark.asyncio
|
@pytest.mark.asyncio
|
||||||
async def test_star_prompt_requires_authenticated_mutation_and_persists_dismissal(
|
async def test_star_prompt_requires_authenticated_mutation_and_persists_dismissal(
|
||||||
bus: MagicMock, tmp_path: Path, monkeypatch: pytest.MonkeyPatch
|
bus: MagicMock,
|
||||||
) -> None:
|
) -> None:
|
||||||
from nanobot.webui.star_prompt import StarPromptState
|
from nanobot.webui.star_prompt import StarPromptState, get_webui_dir
|
||||||
|
|
||||||
monkeypatch.setattr("nanobot.config.paths.get_data_dir", lambda: tmp_path)
|
state_path = get_webui_dir() / "star-prompt.json"
|
||||||
state_path = tmp_path / "webui" / "star-prompt.json"
|
|
||||||
state_path.parent.mkdir()
|
|
||||||
state_path.write_text(StarPromptState(
|
state_path.write_text(StarPromptState(
|
||||||
completed_replies=10, active_days=["2026-09-20", "2026-09-21", "2026-09-22"]
|
completed_replies=10, active_days=["2026-09-20", "2026-09-21", "2026-09-22"]
|
||||||
).model_dump_json(), encoding="utf-8")
|
).model_dump_json(), encoding="utf-8")
|
||||||
|
|||||||
@@ -882,7 +882,7 @@ class TestToolEventProgress:
|
|||||||
},
|
},
|
||||||
)))
|
)))
|
||||||
|
|
||||||
await asyncio.wait_for(first_request_started.wait(), timeout=1)
|
await asyncio.wait_for(first_request_started.wait(), timeout=5)
|
||||||
await loop._pending_queues[session_key].put(InboundMessage(
|
await loop._pending_queues[session_key].put(InboundMessage(
|
||||||
channel="websocket",
|
channel="websocket",
|
||||||
sender_id="user",
|
sender_id="user",
|
||||||
@@ -891,7 +891,8 @@ class TestToolEventProgress:
|
|||||||
session_key_override=session_key,
|
session_key_override=session_key,
|
||||||
))
|
))
|
||||||
release_first_request.set()
|
release_first_request.set()
|
||||||
await asyncio.wait_for(dispatch, timeout=2)
|
# Events synchronize injection; the deadline only guards against a stuck worker.
|
||||||
|
await asyncio.wait_for(dispatch, timeout=5)
|
||||||
|
|
||||||
outbound = []
|
outbound = []
|
||||||
while bus.outbound_size > 0:
|
while bus.outbound_size > 0:
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ from nanobot.webui import star_prompt
|
|||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def state_path(tmp_path, monkeypatch):
|
def state_path(tmp_path, tmp_path_factory):
|
||||||
monkeypatch.setattr(star_prompt, "get_webui_dir", lambda: tmp_path)
|
webui_dir = star_prompt.get_webui_dir()
|
||||||
return tmp_path / "star-prompt.json"
|
assert webui_dir.is_relative_to(tmp_path_factory.getbasetemp())
|
||||||
|
assert not webui_dir.is_relative_to(tmp_path)
|
||||||
|
return webui_dir / "star-prompt.json"
|
||||||
|
|
||||||
|
|
||||||
def seed_eligible(path: Path):
|
def seed_eligible(path: Path):
|
||||||
|
|||||||
Reference in new issue
Block a user