feat: continue roadmap acceptance work
This commit is contained in:
@@ -5,6 +5,7 @@ import pytest
|
||||
|
||||
from rf4_research import community_cli
|
||||
from rf4_research.community_cli import enforce_fetch_interval, fetch_site_key, mark_fetch
|
||||
from rf4_research.community_sources import RF4DBWaterbodyDetail
|
||||
|
||||
|
||||
def test_fetch_cooldown_is_persistent_per_source(tmp_path: Path) -> None:
|
||||
@@ -55,6 +56,39 @@ def test_failed_fetch_still_reserves_site_cooldown(tmp_path: Path, monkeypatch:
|
||||
assert "rf4db.com" in json.loads(state_file.read_text(encoding="utf-8"))
|
||||
|
||||
|
||||
def test_detail_fetch_serializes_single_record(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str],
|
||||
) -> None:
|
||||
state_file = tmp_path / "fetch-state.json"
|
||||
source_url = "https://download.rf4db.com/ru/maps/level_002_kirzah_river"
|
||||
detail = RF4DBWaterbodyDetail(
|
||||
source_system="rf4db",
|
||||
source_external_id="level_002_kirzah_river",
|
||||
source_url=source_url,
|
||||
name="р. Вьюнок",
|
||||
description=None,
|
||||
aliases=(),
|
||||
fish_species=("Щука обыкновенная",),
|
||||
fish_external_ids=("n.pike",),
|
||||
image_urls=(),
|
||||
point_urls=(),
|
||||
)
|
||||
|
||||
monkeypatch.setattr(community_cli, "fetch_html", lambda _url: "<html></html>")
|
||||
monkeypatch.setitem(
|
||||
community_cli.DETAIL_SOURCES,
|
||||
"rf4db-waterbody",
|
||||
lambda _html, *, source_url: detail,
|
||||
)
|
||||
|
||||
assert community_cli.main([
|
||||
"rf4db-waterbody", "--url", source_url, "--state-file", str(state_file),
|
||||
]) == 0
|
||||
payload = json.loads(capsys.readouterr().out)
|
||||
assert payload["source_external_id"] == "level_002_kirzah_river"
|
||||
assert payload["fish_species"] == ["Щука обыкновенная"]
|
||||
|
||||
|
||||
def test_validate_url_host_rejects_disallowed_hosts() -> None:
|
||||
from rf4_research.community_cli import _validate_url_host
|
||||
|
||||
|
||||
Reference in New Issue
Block a user