Add proxy client tests and auxiliary direct downloader

This commit is contained in:
thePR0M3TH3AN committed 2026-04-01 20:37:30 -04:00
1 parent 7b50110f2a
commit 5a8a36b060
4 files changed
+404 -8

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
"""Tests for LBRY client helper behavior."""
from lbry_client import LbryClient
def test_create_odysee_proxy_client_defaults():
client = LbryClient.create_odysee_proxy(timeout=42)
assert client.api_url == LbryClient.ODYSEE_PROXY_URL
assert client.timeout == 42
assert client.backend_name == "Odysee public proxy"
assert client.supports_file_ops is False
def test_find_controlling_channel_uses_claim_search(monkeypatch):
client = LbryClient.create_odysee_proxy()
captured = {}
def fake_claim_search(**kwargs):
captured.update(kwargs)
return {"items": [{"claim_id": "control123", "name": "@example"}]}
monkeypatch.setattr(client, "claim_search", fake_claim_search)
result = client.find_controlling_channel("@example")
assert result == {"claim_id": "control123", "name": "@example"}
assert captured["name"] == "@example"
assert captured["claim_type"] == ["channel"]
assert captured["is_controlling"] is True
assert captured["order_by"] == ["effective_amount"]
assert captured["page"] == 1
assert captured["page_size"] == 1
+69
View File
@@ -0,0 +1,69 @@
"""Tests for main module channel resolution behavior."""
from main import resolve_channel
class FakeProxyClient:
"""Minimal client stub for proxy-backed channel resolution tests."""
supports_file_ops = False
def resolve(self, urls):
uri = urls[0]
return {
uri: {
"claim_id": "vanity123",
"name": "@veritasium",
"value_type": "channel",
"value": {"title": "Veritasium"},
"permanent_url": "lbry://@veritasium#1",
"short_url": "lbry://@veritasium#1",
}
}
def find_controlling_channel(self, channel_name):
assert channel_name == "@veritasium"
return {
"claim_id": "control999",
"name": "@veritasium",
"value_type": "channel",
"value": {"title": "Veritasium"},
"permanent_url": "lbry://@veritasium#f",
"short_url": "lbry://@veritasium#f",
}
class FakeDaemonClient:
"""Minimal client stub for daemon-backed resolution tests."""
supports_file_ops = True
def resolve(self, urls):
uri = urls[0]
return {
uri: {
"claim_id": "daemon123",
"name": "@example",
"value_type": "channel",
"value": {"title": "Example"},
"permanent_url": "lbry://@example#1",
"short_url": "lbry://@example#1",
}
}
def test_resolve_channel_uses_controlling_claim_for_proxy_client():
channel = resolve_channel(FakeProxyClient(), "https://odysee.com/@veritasium:1")
assert channel is not None
assert channel.channel_claim_id == "control999"
assert channel.channel_name == "@veritasium"
def test_resolve_channel_keeps_daemon_claim_id():
channel = resolve_channel(FakeDaemonClient(), "https://odysee.com/@example:1")
assert channel is not None
assert channel.channel_claim_id == "daemon123"
assert channel.channel_name == "@example"