import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent))
from intake.multi_intake import normalize_youtube_published, yt_search
def test_youtube_relative_german_publication_is_normalized():
value = normalize_youtube_published("vor 2 Tagen")
assert "T" in value and value.endswith("+00:00")
def test_youtube_relative_spanish_and_english_publication_is_normalized():
assert "T" in normalize_youtube_published("hace 3 días")
assert "T" in normalize_youtube_published("2 days ago")
assert "T" in normalize_youtube_published("vor 4 Jahren")
def test_youtube_unknown_publication_stays_unknown():
assert normalize_youtube_published("unbekannt") == ""
def test_youtube_topic_search_requests_newest_uploads(monkeypatch):
requested = []
monkeypatch.setattr(
"intake.multi_intake._get",
lambda url, timeout=20: requested.append(url) or b"",
)
assert yt_search("Feuchtigkeit Mallorca") == []
assert requested and "sp=CAI%253D" in requested[0]