CI / checks (push) Skipped
CI / checks (pull_request) Successful in 51s
With no production instance yet, there is no reason to carry two ways
of configuring the agent. Every environment variable that duplicated a
config key is gone; the environment now supplies only the secrets the
file references by ${…}, plus NISSE_CONFIG and NISSE_ENV to find the
files.
- AgentConfig loads from a file (load, from_file) or a parsed tree
(from_tree, for tests); a missing file is an error naming the example
- The from_env constructors on LiteLLMClient, AnthropicPassthroughClient,
GiteaClient, MatrixConfig and RoleMap are removed, with the env
reading for max output tokens; clients take their settings from config
- The live integration tests share a committed agent config,
tests/integration/nisse-test.yaml, aimed at test resources, and one
conftest that loads it and builds clients. NISSE_LIVE_PLANNER_MODEL
becomes its planner role; NISSE_CAPABILITY_MODELS stays as a per-run
switch
- A missing secret now fails the live tests instead of skipping them
- CI passes only the three tokens
- .env.example is secrets only; spec A5 says config comes from the file
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
54 lines
1.9 KiB
Python
54 lines
1.9 KiB
Python
"""Live smoke test against the real homeserver, bound strictly to the
|
|
dedicated test room that nisse-test.yaml names (never the production room)."""
|
|
|
|
import uuid
|
|
|
|
import pytest
|
|
|
|
from nisse_dev.config import AgentConfig
|
|
from nisse_dev.matrix import MatrixConfig, MatrixTransport
|
|
|
|
pytestmark = pytest.mark.integration
|
|
|
|
|
|
def _assert_testing_identity(transport: MatrixTransport, config: MatrixConfig) -> None:
|
|
"""Two invariants that only a live homeserver can check.
|
|
|
|
The configured user id must be the token's real owner, because the
|
|
transport filters its own messages by comparing sender to that value —
|
|
a mismatch would make the bot read its own posts as operator input.
|
|
And tests must run as a testing identity, so a stray live run can never
|
|
act as the production agent.
|
|
"""
|
|
whoami = transport._http.get("/account/whoami")
|
|
whoami.raise_for_status()
|
|
actual = whoami.json()["user_id"]
|
|
assert actual == config.user_id, (
|
|
f"matrix.user_id is {config.user_id} but the token belongs to "
|
|
f"{actual}; the self-message filter would not match"
|
|
)
|
|
assert "testing" in actual, (
|
|
f"live tests must run as a testing identity, not {actual}"
|
|
)
|
|
|
|
|
|
def test_send_lands_in_test_room(live_config: AgentConfig) -> None:
|
|
config = live_config.matrix
|
|
marker = f"transport smoke test {uuid.uuid4().hex}"
|
|
transport = MatrixTransport(config)
|
|
try:
|
|
_assert_testing_identity(transport, config)
|
|
transport.send_message(marker)
|
|
response = transport._http.get(
|
|
f"/rooms/{config.room_id}/messages",
|
|
params={"dir": "b", "limit": "10"},
|
|
)
|
|
response.raise_for_status()
|
|
bodies = [
|
|
event.get("content", {}).get("body")
|
|
for event in response.json().get("chunk", [])
|
|
]
|
|
assert marker in bodies
|
|
finally:
|
|
transport.close()
|