Agent-Reach/tests/test_core.py
Panniantong 74c3df5c3d v2.0.0 — Pure glue architecture: zero copied code, pluggable channels
BREAKING: Complete architectural rewrite.

Before: Copied x-reader's fetcher code into readers/ (1205 lines of borrowed code)
After: Pluggable channel system where each channel is a thin wrapper (~50 lines)
       around the best external tool for that platform. Zero copied code.

Architecture:
- channels/base.py — Universal Channel interface (read, search, check)
- channels/web.py — Jina Reader API (swappable)
- channels/github.py — GitHub API (swappable)
- channels/twitter.py — birdx + Jina fallback (swappable)
- channels/youtube.py — yt-dlp (swappable)
- channels/reddit.py — Reddit JSON API + proxy (swappable)
- channels/rss.py — feedparser (swappable)
- channels/bilibili.py — Bilibili API (swappable)
- channels/exa_search.py — Exa semantic search (swappable)

Key design: every backend can be swapped by changing ONE file.
YouTube dies? Change youtube.py. Exa sucks? Swap exa_search.py for Tavily.
Nothing else changes.

Removed: reader.py, schema.py, readers/, search/, utils/ (all x-reader code)
Tests: 36/36 passing
2026-02-24 05:38:21 +01:00

36 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
"""Tests for AgentEyes core class."""
import pytest
from agent_eyes.config import Config
from agent_eyes.core import AgentEyes
@pytest.fixture
def eyes(tmp_path):
config = Config(config_path=tmp_path / "config.yaml")
return AgentEyes(config=config)
class TestAgentEyes:
def test_init(self, eyes):
assert eyes.config is not None
def test_detect_platform(self, eyes):
assert eyes.detect_platform("https://github.com/test/repo") == "github"
assert eyes.detect_platform("https://reddit.com/r/test") == "reddit"
assert eyes.detect_platform("https://x.com/user/status/123") == "twitter"
assert eyes.detect_platform("https://youtube.com/watch?v=abc") == "youtube"
assert eyes.detect_platform("https://bilibili.com/video/BV1xx") == "bilibili"
assert eyes.detect_platform("https://example.com") == "web"
def test_doctor(self, eyes):
results = eyes.doctor()
assert isinstance(results, dict)
assert "web" in results
assert "github" in results
def test_doctor_report(self, eyes):
report = eyes.doctor_report()
assert isinstance(report, str)
assert "Agent Eyes" in report