style: apply ruff format across backend + scripts (line-length 100)
Mechanical, whole-tree `ruff format` pass — no behaviour change. Recorded in .git-blame-ignore-revs (next commit) so git blame skips it.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
"""Per-source adapter selection + the source-specific policy each one carries. These lock the
|
||||
behaviour that used to live inline in worker.build_uploader_url / backfill._should_refetch."""
|
||||
|
||||
from app.downloads.adapters import (
|
||||
FacebookAdapter,
|
||||
RedditAdapter,
|
||||
@@ -30,7 +31,10 @@ def test_host_match_is_netloc_not_a_loose_substring():
|
||||
def test_info_match_is_extractor_key_not_the_webpage_url():
|
||||
# The webpage_url path may carry a SIBLING source's name (a reddit slug about youtube); only the
|
||||
# yt-dlp extractor_key identifies the source, so this must resolve reddit, not youtube.
|
||||
info = {"extractor_key": "Reddit", "webpage_url": "https://reddit.com/r/x/comments/y/youtube_is_dead"}
|
||||
info = {
|
||||
"extractor_key": "Reddit",
|
||||
"webpage_url": "https://reddit.com/r/x/comments/y/youtube_is_dead",
|
||||
}
|
||||
assert resolve_adapter("url", None, info).key == "reddit"
|
||||
|
||||
|
||||
@@ -53,16 +57,27 @@ def test_lookalike_hosts_do_not_misresolve_but_subdomains_do():
|
||||
def test_webpage_url_netloc_identifies_source_when_extractor_key_absent():
|
||||
# The early-fill path passes info with no source_ref; the webpage_url netloc still resolves the
|
||||
# source even if extractor_key is missing from the progress-hook info_dict.
|
||||
assert resolve_adapter(None, None, {"webpage_url": "https://www.facebook.com/reel/123"}).key == "facebook"
|
||||
assert (
|
||||
resolve_adapter(None, None, {"webpage_url": "https://www.facebook.com/reel/123"}).key
|
||||
== "facebook"
|
||||
)
|
||||
# A sibling source's name in the webpage_url PATH must not misresolve (host, not substring).
|
||||
info = {"extractor_key": "Reddit", "webpage_url": "https://www.reddit.com/r/x/comments/y/youtube"}
|
||||
info = {
|
||||
"extractor_key": "Reddit",
|
||||
"webpage_url": "https://www.reddit.com/r/x/comments/y/youtube",
|
||||
}
|
||||
assert resolve_adapter(None, None, info).key == "reddit"
|
||||
|
||||
|
||||
def test_uploader_url_youtube_uses_channel_url():
|
||||
a = YouTubeAdapter()
|
||||
assert a.uploader_url({"channel_url": "https://youtube.com/@chan"}) == "https://youtube.com/@chan"
|
||||
assert a.uploader_url({"uploader_url": "https://youtube.com/user/u"}) == "https://youtube.com/user/u"
|
||||
assert (
|
||||
a.uploader_url({"channel_url": "https://youtube.com/@chan"}) == "https://youtube.com/@chan"
|
||||
)
|
||||
assert (
|
||||
a.uploader_url({"uploader_url": "https://youtube.com/user/u"})
|
||||
== "https://youtube.com/user/u"
|
||||
)
|
||||
assert a.uploader_url({}) is None
|
||||
|
||||
|
||||
@@ -83,7 +98,9 @@ def test_uploader_url_reddit_and_generic_have_no_channel():
|
||||
|
||||
def test_generic_source_url_is_passthrough_youtube_reconstructs():
|
||||
assert SourceAdapter().source_url("https://x/y") == "https://x/y"
|
||||
assert YouTubeAdapter().source_url("VIDID12345_") == "https://www.youtube.com/watch?v=VIDID12345_"
|
||||
assert (
|
||||
YouTubeAdapter().source_url("VIDID12345_") == "https://www.youtube.com/watch?v=VIDID12345_"
|
||||
)
|
||||
|
||||
|
||||
def test_client_sets_and_retriable_are_youtube_only():
|
||||
|
||||
Reference in New Issue
Block a user