mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-05-06 16:36:45 -03:00
test(network): align cooldown short-circuit test with per-host guard
This commit is contained in:
@@ -74,22 +74,29 @@ async def test_connectivity_guard_recovers_after_success():
|
|||||||
|
|
||||||
async def test_downloader_short_circuits_all_request_helpers_during_cooldown():
|
async def test_downloader_short_circuits_all_request_helpers_during_cooldown():
|
||||||
guard = await ConnectivityGuard.get_instance()
|
guard = await ConnectivityGuard.get_instance()
|
||||||
guard.cooldown_until = datetime.now() + timedelta(seconds=30)
|
destination = "example.invalid"
|
||||||
guard.online = False
|
guard.register_network_failure(
|
||||||
guard.failure_count = 3
|
OSError(errno.ENETUNREACH, "unreachable"),
|
||||||
|
destination,
|
||||||
|
)
|
||||||
|
guard.register_network_failure(asyncio.TimeoutError("timeout"), destination)
|
||||||
|
guard.register_network_failure(
|
||||||
|
ConnectionRefusedError("refused"),
|
||||||
|
destination,
|
||||||
|
)
|
||||||
|
|
||||||
downloader = Downloader()
|
downloader = Downloader()
|
||||||
|
|
||||||
ok, payload = await downloader.make_request("GET", "https://example.invalid")
|
ok, payload = await downloader.make_request("GET", f"https://{destination}")
|
||||||
assert ok is False
|
assert ok is False
|
||||||
assert payload == OFFLINE_COOLDOWN_ERROR
|
assert payload == OFFLINE_COOLDOWN_ERROR
|
||||||
|
|
||||||
ok, payload, headers = await downloader.download_to_memory("https://example.invalid")
|
ok, payload, headers = await downloader.download_to_memory(f"https://{destination}")
|
||||||
assert ok is False
|
assert ok is False
|
||||||
assert payload == OFFLINE_COOLDOWN_ERROR
|
assert payload == OFFLINE_COOLDOWN_ERROR
|
||||||
assert headers is None
|
assert headers is None
|
||||||
|
|
||||||
ok, payload = await downloader.get_response_headers("https://example.invalid")
|
ok, payload = await downloader.get_response_headers(f"https://{destination}")
|
||||||
assert ok is False
|
assert ok is False
|
||||||
assert payload == OFFLINE_COOLDOWN_ERROR
|
assert payload == OFFLINE_COOLDOWN_ERROR
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user