"""Live smoke test against the real homeserver, bound strictly to the dedicated test room (never the production room). Skips unless the Matrix env vars, including NISSE_MATRIX_TEST_ROOM_ID, are present.""" import os import uuid from pathlib import Path import pytest from nisse_dev.envfile import load_env_file from nisse_dev.matrix import MatrixConfig, MatrixTransport load_env_file(Path(__file__).resolve().parents[2] / ".env") REQUIRED = ( "NISSE_MATRIX_HOMESERVER", "NISSE_MATRIX_USER_ID", "NISSE_MATRIX_TOKEN", "NISSE_MATRIX_TEST_ROOM_ID", ) pytestmark = [ pytest.mark.integration, pytest.mark.skipif( not all(os.environ.get(var) for var in REQUIRED), reason=f"live matrix config absent; set {', '.join(REQUIRED)}", ), ] def test_send_lands_in_test_room() -> None: config = MatrixConfig.from_env(room_var="NISSE_MATRIX_TEST_ROOM_ID") marker = f"transport smoke test {uuid.uuid4().hex}" transport = MatrixTransport(config) try: 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()