离线 mock 测试 generate 产出,GitHub Actions 跑 pytest,30 分钟内重复调度自动 skip。 Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
1.4 KiB
Python
51 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
import json
|
|
from datetime import datetime, timedelta, timezone
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
FIXTURES = Path(__file__).parent / "fixtures"
|
|
|
|
|
|
@pytest.fixture
|
|
def skills_feed() -> dict:
|
|
return json.loads((FIXTURES / "skills-feed.json").read_text(encoding="utf-8"))
|
|
|
|
|
|
@pytest.fixture
|
|
def fixed_cst():
|
|
return datetime(2026, 7, 3, 9, 30, tzinfo=timezone(timedelta(hours=8)))
|
|
|
|
|
|
@pytest.fixture
|
|
def isolated_output(tmp_path, monkeypatch):
|
|
import daily.config as config
|
|
import daily.report_data as report_data
|
|
|
|
out = tmp_path / "output"
|
|
cache = tmp_path / "cache"
|
|
logs = tmp_path / "logs"
|
|
out.mkdir()
|
|
cache.mkdir()
|
|
logs.mkdir()
|
|
monkeypatch.setattr(config, "OUTPUT_DIR", out)
|
|
monkeypatch.setattr(report_data, "OUTPUT_DIR", out)
|
|
monkeypatch.setattr(config, "CACHE_DIR", cache)
|
|
monkeypatch.setattr(config, "LOG_DIR", logs)
|
|
monkeypatch.setattr(config, "SNAPSHOT_FILE", cache / "last-report.json")
|
|
return out
|
|
|
|
|
|
@pytest.fixture
|
|
def offline_generate_env(monkeypatch):
|
|
monkeypatch.setenv("DAILY_AI_NEWS", "0")
|
|
monkeypatch.setenv("DAILY_CN_AI_NEWS", "0")
|
|
monkeypatch.setenv("DAILY_ZH_DESC", "0")
|
|
monkeypatch.setenv("SKILLS_BOARD_SOURCE", "feed")
|
|
monkeypatch.setenv("DAILY_REPORT_MODE", "classic")
|
|
monkeypatch.setenv("DAILY_CURSOR_EDITOR", "0")
|
|
monkeypatch.setenv("DAILY_TRENDING_LIMIT", "10")
|
|
monkeypatch.setenv("DAILY_HOT_LIMIT", "10")
|