sources: панели не схлопываются с rad_ того же домена (175 вместо 5 в реестре); тесты уникальности по (url, adapter)
Some checks failed
ci / test (3.10) (push) Has been cancelled
ci / test (3.11) (push) Has been cancelled
ci / test (3.12) (push) Has been cancelled

This commit is contained in:
Vlad Gothbreach
2026-10-27 04:09:59 +03:00
parent 1781983027
commit 0831984918
4 changed files with 11 additions and 5 deletions

View File

@@ -277,7 +277,7 @@ def test_quality_wave_is_integrated_without_collisions():
assert all(isinstance(s.tags, tuple) and s.adapter in feeds.ADAPTERS for s in wave)
assert {s.name for s in wave} <= {s.name for s in registry}
assert len(registry) == len({s.name.strip().lower() for s in registry})
assert len(registry) == len({s.url.rstrip("/").lower() for s in registry})
assert len(registry) == len({(s.url.rstrip("/").lower(), s.adapter) for s in registry})
@pytest.mark.parametrize("tags", [(), ("news",), ("news", "cve")])

View File

@@ -122,8 +122,10 @@ def test_bot_not_claimable_by_first_writer(monkeypatch):
# ---------- 6. реестр без дублей ----------
def test_sources_unique():
from omni import sources
urls = [s.url.rstrip("/").lower() for s in sources.all_sources() if s.url]
assert len(urls) == len(set(urls)), "в реестре дубли по url"
# Панель (newapi_pricing) и обход сайта (html_listing) на одном домене — разные источники,
# поэтому уникальность проверяем по паре (url, adapter), а не по голому url.
keys = [(s.url.rstrip("/").lower(), s.adapter) for s in sources.all_sources() if s.url]
assert len(keys) == len(set(keys)), "в реестре дубли по (url, adapter)"
# ---------- 7. JOBS не растёт бесконечно ----------

View File

@@ -46,8 +46,8 @@ def test_cn_sources_registered():
def test_all_sources_no_dup_url():
seen = {}
for s in sources.all_sources():
u = (s.url or "").rstrip("/").lower()
assert u not in seen, "дубль url: %s" % s.name
u = ((s.url or "").rstrip("/").lower(), s.adapter)
assert u not in seen, "дубль (url, adapter): %s" % s.name
seen[u] = s.name