37 lines
1 KiB
Python
37 lines
1 KiB
Python
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
from repub.config import FeedConfig
|
|
from repub.job_runner import _build_crawl_settings
|
|
|
|
|
|
def test_build_crawl_settings_passes_feed_url_to_spider(tmp_path: Path) -> None:
|
|
settings = _build_crawl_settings(
|
|
out_dir=tmp_path / "out",
|
|
feed=FeedConfig(
|
|
name="Demo Feed",
|
|
slug="demo",
|
|
url="https://source.example/feed.rss",
|
|
),
|
|
stats_path=tmp_path / "stats.jsonl",
|
|
feed_url="https://mirror.example",
|
|
)
|
|
|
|
assert settings["REPUBLISHER_FEED_URL"] == "https://mirror.example"
|
|
|
|
|
|
def test_build_crawl_settings_requires_non_empty_feed_url(
|
|
tmp_path: Path,
|
|
) -> None:
|
|
with pytest.raises(ValueError, match="feed_url setting is required"):
|
|
_build_crawl_settings(
|
|
out_dir=tmp_path / "out",
|
|
feed=FeedConfig(
|
|
name="Demo Feed",
|
|
slug="demo",
|
|
url="https://source.example/feed.rss",
|
|
),
|
|
stats_path=tmp_path / "stats.jsonl",
|
|
feed_url="",
|
|
)
|