| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- """Integration tests against the live Chatto Connect API.
- Run with: pytest tests/test_integration.py -v
- Requires: CHATTO_LOGIN and CHATTO_PASSWORD environment variables.
- """
- import os
- import pytest
- from chattolib.client import ChattoClient
- from chattolib.exceptions import ChattoAuthError
- pytestmark = pytest.mark.skipif(
- not os.environ.get("CHATTO_LOGIN") or not os.environ.get("CHATTO_PASSWORD"),
- reason="CHATTO_LOGIN and CHATTO_PASSWORD env vars required",
- )
- @pytest.fixture
- async def client():
- c = await ChattoClient.login(
- os.environ["CHATTO_LOGIN"],
- os.environ["CHATTO_PASSWORD"],
- )
- async with c:
- yield c
- async def test_login_and_me(client):
- user = await client.me()
- assert user.id
- assert user.login == os.environ["CHATTO_LOGIN"]
- print(f"Logged in as {user.login} (id={user.id})")
- async def test_invalid_login():
- with pytest.raises(ChattoAuthError, match="Invalid credentials"):
- await ChattoClient.login("nonexistent_user_xyz", "wrongpassword")
- async def test_list_rooms(client):
- rooms = await client.list_rooms()
- assert isinstance(rooms, list)
- print(f"Found {len(rooms)} rooms")
- for r in rooms:
- if r.room is None:
- continue
- print(f" - {r.room.name} (id={r.room.id}, kind={r.room.kind.name})")
- async def test_public_server_metadata():
- async with ChattoClient() as anonymous:
- profile, login = await anonymous.get_server()
- assert profile.name
- assert profile.version
- print(f"Chatto {profile.version} — {profile.name}")
- print(f"Direct registration: {login.direct_registration_enabled}")
|