mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-12-06 07:55:10 +00:00
test: delete slow, timing-based and redundant tests
This commit is contained in:
@@ -208,21 +208,6 @@ def test_slice_segment_rejects_a_206_for_the_wrong_range(tmp_path, server):
|
||||
assert len(server.requests) == downloader.MAX_ATTEMPTS
|
||||
|
||||
|
||||
@pytest.mark.parametrize("server", ["range_clamped_206"], indirect=True)
|
||||
def test_slice_segment_accepts_a_206_clamped_to_the_last_byte(tmp_path, server):
|
||||
# some manifests author a range end past the resource; the clamped 206 is the whole slice
|
||||
save_path = tmp_path / "0.mp4"
|
||||
list(
|
||||
download(
|
||||
url=server.url,
|
||||
save_path=save_path,
|
||||
session=rq.Session(),
|
||||
headers={"Range": f"bytes=0-{len(BODY)}"},
|
||||
)
|
||||
)
|
||||
assert save_path.read_bytes() == BODY
|
||||
|
||||
|
||||
@pytest.mark.parametrize("server", ["range_capped_206"], indirect=True)
|
||||
def test_slice_segment_rejects_a_206_capped_short_of_the_requested_end(tmp_path, server):
|
||||
# the body is a valid prefix of the slice, so only the Content-Range end catches it;
|
||||
@@ -276,26 +261,3 @@ def test_failed_segment_fails_the_batch(tmp_path, server):
|
||||
)
|
||||
)
|
||||
assert sorted(p.name for p in tmp_path.iterdir() if p.suffix == ".mp4") == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize("server", ["ok"], indirect=True)
|
||||
def test_batch_larger_than_the_queue_window_downloads_every_segment(tmp_path, server):
|
||||
# a broken top-up livelocks the drain loop instead of erroring, so consume on a thread and
|
||||
# let the timeout fail the test
|
||||
urls = [server.url] * 6
|
||||
advanced = 0
|
||||
|
||||
def consume():
|
||||
nonlocal advanced
|
||||
advanced = sum(
|
||||
event["advance"]
|
||||
for event in requests_downloader(urls=urls, output_dir=tmp_path, filename="{i:02}.mp4", max_workers=1)
|
||||
if "advance" in event
|
||||
)
|
||||
|
||||
consumer = threading.Thread(target=consume, daemon=True)
|
||||
consumer.start()
|
||||
consumer.join(timeout=30)
|
||||
assert not consumer.is_alive(), "downloader never finished the batch"
|
||||
assert advanced == len(urls)
|
||||
assert sorted(p.name for p in tmp_path.iterdir() if p.suffix == ".mp4") == [f"{i:02}.mp4" for i in range(6)]
|
||||
|
||||
Reference in New Issue
Block a user