free-claude-code/smoke/test_messaging_live.py
Ali Khokhar 462a9430bb
Add local live smoke test suite (#148)
## Summary
- add an opt-in local `smoke/` pytest suite for API, auth, providers,
CLI, IDE-shaped requests, messaging, voice, tools, and thinking stream
contracts
- keep smoke tests out of normal CI collection with `testpaths =
["tests"]`
- write sanitized smoke artifacts under `.smoke-results/`

## Verification
- `uv run ruff format`
- `uv run ruff check`
- `uv run ty check`
- `uv run ty check smoke`
- `FCC_LIVE_SMOKE=1 FCC_SMOKE_TARGETS=all FCC_SMOKE_RUN_VOICE=1 uv run
pytest smoke -n 0 -m live -s --tb=short` -> 17 passed, 9 skipped
- `uv run pytest` -> 904 passed

## Notes
- Skipped live checks require local credentials/tools/services, such as
provider models, Telegram/Discord targets, voice backend, or Claude CLI.
- `claude-pick` smoke was intentionally removed.
2026-04-23 19:06:09 -07:00

113 lines
3.7 KiB
Python

from __future__ import annotations
import os
import time
import httpx
import pytest
from smoke.lib.config import SmokeConfig
@pytest.mark.live
@pytest.mark.smoke_target("telegram")
def test_telegram_bot_api_permissions(smoke_config: SmokeConfig) -> None:
token = smoke_config.settings.telegram_bot_token
if not token:
pytest.skip("TELEGRAM_BOT_TOKEN is not configured")
base_url = f"https://api.telegram.org/bot{token}"
get_me = httpx.get(f"{base_url}/getMe", timeout=smoke_config.timeout_s)
assert get_me.status_code == 200, get_me.text
assert get_me.json()["ok"] is True
chat_id = os.getenv("FCC_SMOKE_TELEGRAM_CHAT_ID") or (
smoke_config.settings.allowed_telegram_user_id or ""
)
if not chat_id:
pytest.skip("FCC_SMOKE_TELEGRAM_CHAT_ID or ALLOWED_TELEGRAM_USER_ID required")
marker = f"FCC smoke {int(time.time())}"
sent = httpx.post(
f"{base_url}/sendMessage",
json={"chat_id": chat_id, "text": marker},
timeout=smoke_config.timeout_s,
)
assert sent.status_code == 200, sent.text
message_id = sent.json()["result"]["message_id"]
edited = httpx.post(
f"{base_url}/editMessageText",
json={"chat_id": chat_id, "message_id": message_id, "text": marker + " edit"},
timeout=smoke_config.timeout_s,
)
assert edited.status_code == 200, edited.text
deleted = httpx.post(
f"{base_url}/deleteMessage",
json={"chat_id": chat_id, "message_id": message_id},
timeout=smoke_config.timeout_s,
)
assert deleted.status_code == 200, deleted.text
@pytest.mark.live
@pytest.mark.smoke_target("discord")
def test_discord_bot_api_permissions(smoke_config: SmokeConfig) -> None:
token = smoke_config.settings.discord_bot_token
channel_id = os.getenv("FCC_SMOKE_DISCORD_CHANNEL_ID")
if not channel_id and smoke_config.settings.allowed_discord_channels:
channel_id = smoke_config.settings.allowed_discord_channels.split(",", 1)[0]
if not token:
pytest.skip("DISCORD_BOT_TOKEN is not configured")
if not channel_id:
pytest.skip("FCC_SMOKE_DISCORD_CHANNEL_ID or ALLOWED_DISCORD_CHANNELS required")
headers = {"authorization": f"Bot {token}"}
base_url = "https://discord.com/api/v10"
channel = httpx.get(
f"{base_url}/channels/{channel_id}",
headers=headers,
timeout=smoke_config.timeout_s,
)
assert channel.status_code == 200, channel.text
marker = f"FCC smoke {int(time.time())}"
sent = httpx.post(
f"{base_url}/channels/{channel_id}/messages",
headers=headers,
json={"content": marker},
timeout=smoke_config.timeout_s,
)
assert sent.status_code == 200, sent.text
message_id = sent.json()["id"]
edited = httpx.patch(
f"{base_url}/channels/{channel_id}/messages/{message_id}",
headers=headers,
json={"content": marker + " edit"},
timeout=smoke_config.timeout_s,
)
assert edited.status_code == 200, edited.text
deleted = httpx.delete(
f"{base_url}/channels/{channel_id}/messages/{message_id}",
headers=headers,
timeout=smoke_config.timeout_s,
)
assert deleted.status_code in {200, 204}, deleted.text
@pytest.mark.live
@pytest.mark.smoke_target("telegram")
@pytest.mark.smoke_target("discord")
def test_interactive_inbound_messaging_requires_explicit_mode(
smoke_config: SmokeConfig,
) -> None:
if not smoke_config.interactive:
pytest.skip("set FCC_SMOKE_INTERACTIVE=1 for manual inbound messaging checks")
pytest.skip(
"manual inbound check: start the server, send a nonce from the real client, "
"and verify threaded progress plus /stop, /clear, and /stats"
)