Agent-Reach/tests/test_channels.py
Pnant 00d80d2169
remove: drop Boss直聘 channel (non-functional) (#135)
Boss直聘 channel removed entirely — upstream mcp-bosszp
triggers account-level bans, making it unusable in practice.

Removed from: channel registry, README (CN/EN), install.md,
SKILL.md, tests, credits.

Co-authored-by: Panniantong <panniantong@users.noreply.github.com>
2026-03-10 10:14:59 +08:00

44 lines
1.6 KiB
Python

# -*- coding: utf-8 -*-
"""Tests for channel registry basics and health checks."""
import shutil
import subprocess
from agent_reach.channels import get_all_channels, get_channel
from agent_reach.channels.xiaohongshu import XiaoHongShuChannel
class TestChannelRegistry:
def test_get_channel_by_name(self):
ch = get_channel("github")
assert ch is not None
assert ch.name == "github"
def test_get_unknown_channel_returns_none(self):
assert get_channel("not-exists") is None
def test_all_channels_registered(self):
channels = get_all_channels()
names = [ch.name for ch in channels]
assert "web" in names
assert "github" in names
assert "twitter" in names
class TestXiaoHongShuChannel:
def test_reports_ok_when_server_health_is_ok(self, monkeypatch):
monkeypatch.setattr(shutil, "which", lambda _: "/opt/homebrew/bin/mcporter")
def fake_run(cmd, **kwargs):
if cmd[:4] == ["/opt/homebrew/bin/mcporter", "config", "get", "xiaohongshu"]:
return subprocess.CompletedProcess(cmd, 0, '{"name":"xiaohongshu"}', "")
if cmd[:4] == ["/opt/homebrew/bin/mcporter", "list", "xiaohongshu", "--json"]:
return subprocess.CompletedProcess(cmd, 0, '{"status": "ok"}', "")
raise AssertionError(f"unexpected command: {cmd}")
monkeypatch.setattr(subprocess, "run", fake_run)
assert XiaoHongShuChannel().check() == (
"ok",
"MCP 已连接(阅读、搜索、发帖、评论、点赞)",
)