output to out/feeds/*
This commit is contained in:
parent
beac981047
commit
6fd3b598ab
11 changed files with 298 additions and 16 deletions
|
|
@ -1,6 +1,10 @@
|
|||
from pathlib import Path
|
||||
|
||||
from scrapy.settings import Settings
|
||||
|
||||
from repub import entrypoint as entrypoint_module
|
||||
from repub.spiders.rss_spider import RssFeedSpider
|
||||
from repub.utils import FileType, local_audio_path, local_image_path
|
||||
|
||||
|
||||
def test_entrypoint_supports_file_feed_urls(tmp_path: Path, monkeypatch) -> None:
|
||||
|
|
@ -29,9 +33,33 @@ DOWNLOAD_TIMEOUT = 5
|
|||
|
||||
exit_code = entrypoint_module.entrypoint(["--config", str(config_path)])
|
||||
|
||||
output_path = tmp_path / "out" / "local-file" / "feed.rss"
|
||||
output_path = tmp_path / "out" / "feeds" / "local-file" / "feed.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
|
||||
|
||||
|
||||
def test_rss_spider_rewrites_public_asset_urls_as_relative_paths() -> None:
|
||||
spider = RssFeedSpider(feed_name="demo", url="https://example.com/feed.rss")
|
||||
spider.settings = Settings(
|
||||
values={
|
||||
"REPUBLISHER_IMAGE_DIR": "images",
|
||||
"REPUBLISHER_FILE_DIR": "files",
|
||||
"REPUBLISHER_AUDIO_DIR": "audio",
|
||||
"REPUBLISHER_VIDEO_DIR": "video",
|
||||
}
|
||||
)
|
||||
|
||||
assert (
|
||||
spider.rewrite_image_url("https://example.com/media/photo.jpg")
|
||||
== f"images/{local_image_path('https://example.com/media/photo.jpg')}"
|
||||
)
|
||||
assert (
|
||||
spider.rewrite_file_url(
|
||||
FileType.AUDIO,
|
||||
"https://example.com/media/podcast.mp3",
|
||||
)
|
||||
== f"audio/{local_audio_path('https://example.com/media/podcast.mp3')}"
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue