republisher/tests/test_file_feeds.py

37 lines
1,015 B
Python

from pathlib import Path
from repub import entrypoint as entrypoint_module
def test_entrypoint_supports_file_feed_urls(tmp_path: Path, monkeypatch) -> None:
fixture_path = (
Path(__file__).resolve().parents[1] / "demo" / "fixtures" / "local-feed.rss"
).resolve()
config_path = tmp_path / "repub.toml"
config_path.write_text(
f"""
out_dir = "out"
[[feeds]]
name = "Local Demo"
slug = "local-file"
url = "{fixture_path.as_uri()}"
[scrapy.settings]
LOG_LEVEL = "ERROR"
DOWNLOAD_TIMEOUT = 5
""".strip()
+ "\n",
encoding="utf-8",
)
monkeypatch.setattr(entrypoint_module, "check_runtime", lambda *_: True)
exit_code = entrypoint_module.entrypoint(["--config", str(config_path)])
output_path = tmp_path / "out" / "local-file.rss"
assert exit_code == 0
assert output_path.exists()
output = output_path.read_text(encoding="utf-8")
assert "<title>Local Demo Feed</title>" in output
assert "<title>Local Demo Entry</title>" in output