feat(n7web): sync N7 scene cards and optimize runtime

This commit is contained in:
Miayui
2026-09-17 11:04:05 +08:00
parent 75ce391312
commit 7d196db02b
31 changed files with 2924 additions and 126 deletions
+36
View File
@@ -0,0 +1,36 @@
from __future__ import annotations
import socket
from types import SimpleNamespace
import pytest
from tools import start_n7web
def test_tcp_port_probe_detects_an_existing_listener() -> None:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as listener:
listener.bind(("127.0.0.1", 0))
listener.listen(1)
assert start_n7web._tcp_port_is_listening( # noqa: SLF001
"0.0.0.0",
listener.getsockname()[1],
)
def test_startup_rejects_a_duplicate_service_port(monkeypatch: pytest.MonkeyPatch) -> None:
args = SimpleNamespace(
host="127.0.0.1",
port=8000,
scene_bind="0.0.0.0",
scene_port=8090,
)
monkeypatch.setattr(
start_n7web,
"_tcp_port_is_listening",
lambda _host, port: port == 8000,
)
with pytest.raises(RuntimeError, match="stop the previous N7Web instance"):
start_n7web._ensure_service_ports_available(args) # noqa: SLF001