chore: snapshot current project updates
This commit is contained in:
@@ -92,6 +92,18 @@ class TestByQuality:
|
||||
idx = choose_keep_index(items, "by_quality", quality_comparison=qc)
|
||||
assert idx == 0
|
||||
|
||||
def test_by_quality_deprioritizes_sample(self):
|
||||
"""Sample clip should lose to normal release when quality is equal."""
|
||||
p1 = Path("/movies/Test.2020.Sample.1080p.BluRay.mkv")
|
||||
p2 = Path("/movies/Test.2020.1080p.BluRay.mkv")
|
||||
items = [(p1, _mi()), (p2, _mi())]
|
||||
qc = [
|
||||
{"path": str(p1), "resolution": "1920x1080", "size_bytes": 1000000},
|
||||
{"path": str(p2), "resolution": "1920x1080", "size_bytes": 1000000},
|
||||
]
|
||||
idx = choose_keep_index(items, "by_quality", quality_comparison=qc)
|
||||
assert idx == 1
|
||||
|
||||
|
||||
class TestOtherStrategies:
|
||||
"""Tests for by_reputation, first_seen, manual."""
|
||||
@@ -117,3 +129,92 @@ class TestOtherStrategies:
|
||||
]
|
||||
idx = choose_keep_index(items, "by_reputation")
|
||||
assert idx == 1
|
||||
|
||||
def test_by_reputation_deprioritizes_sample(self):
|
||||
"""Sample clip should not be selected even with identical reputation."""
|
||||
a = _mi()
|
||||
a.reputation_score = 8.0
|
||||
a.reputation_votes = 300
|
||||
b = _mi()
|
||||
b.reputation_score = 8.0
|
||||
b.reputation_votes = 300
|
||||
items = [
|
||||
(Path("/a/Test.Sample.mkv"), a),
|
||||
(Path("/a/Test.Final.mkv"), b),
|
||||
]
|
||||
idx = choose_keep_index(items, "by_reputation")
|
||||
assert idx == 1
|
||||
|
||||
def test_by_reputation_falls_back_to_quality_when_reputation_missing(self):
|
||||
"""When reputation is missing, BluRay should beat WEB-DL."""
|
||||
a = _mi()
|
||||
a.reputation_score = None
|
||||
a.reputation_votes = None
|
||||
b = _mi()
|
||||
b.reputation_score = None
|
||||
b.reputation_votes = None
|
||||
p_web = Path("/a/Test.2020.2160p.WEB-DL.HEVC.mkv")
|
||||
p_bluray = Path("/a/Test.2020.1080p.BluRay.x265.mkv")
|
||||
items = [(p_web, a), (p_bluray, b)]
|
||||
qc = [
|
||||
{"path": str(p_web), "resolution": "3840x2160", "codec": "hevc", "size_bytes": 24000000000},
|
||||
{"path": str(p_bluray), "resolution": "1920x1080", "codec": "hevc", "size_bytes": 8000000000},
|
||||
]
|
||||
idx = choose_keep_index(items, "by_reputation", quality_comparison=qc)
|
||||
assert idx == 1
|
||||
|
||||
def test_by_reputation_quality_time_prefers_quality_after_reputation(self):
|
||||
"""When reputation ties, quality should decide before modified time."""
|
||||
a = _mi()
|
||||
a.reputation_score = 8.0
|
||||
a.reputation_votes = 300
|
||||
b = _mi()
|
||||
b.reputation_score = 8.0
|
||||
b.reputation_votes = 300
|
||||
p1 = Path("/a/Test.2020.720p.WEB-DL.mkv")
|
||||
p2 = Path("/a/Test.2020.1080p.BluRay.mkv")
|
||||
items = [(p1, a), (p2, b)]
|
||||
qc = [
|
||||
{
|
||||
"path": str(p1),
|
||||
"resolution": "1280x720",
|
||||
"size_bytes": 1000000,
|
||||
"modified_timestamp": "2026-02-01T00:00:00+00:00",
|
||||
},
|
||||
{
|
||||
"path": str(p2),
|
||||
"resolution": "1920x1080",
|
||||
"size_bytes": 2000000,
|
||||
"modified_timestamp": "2025-01-01T00:00:00+00:00",
|
||||
},
|
||||
]
|
||||
idx = choose_keep_index(items, "by_reputation_quality_time", quality_comparison=qc)
|
||||
assert idx == 1
|
||||
|
||||
def test_by_reputation_quality_time_prefers_newer_when_rep_and_quality_tie(self):
|
||||
"""When reputation and quality tie, newer modified timestamp wins."""
|
||||
a = _mi()
|
||||
a.reputation_score = 8.0
|
||||
a.reputation_votes = 300
|
||||
b = _mi()
|
||||
b.reputation_score = 8.0
|
||||
b.reputation_votes = 300
|
||||
p1 = Path("/a/Test.2020.1080p.BluRay.mkv")
|
||||
p2 = Path("/a/Test.2020.1080p.BluRay.mkv")
|
||||
items = [(p1, a), (p2, b)]
|
||||
qc = [
|
||||
{
|
||||
"path": str(p1),
|
||||
"resolution": "1920x1080",
|
||||
"size_bytes": 2000000,
|
||||
"modified_timestamp": "2025-01-01T00:00:00+00:00",
|
||||
},
|
||||
{
|
||||
"path": str(p2),
|
||||
"resolution": "1920x1080",
|
||||
"size_bytes": 2000000,
|
||||
"modified_timestamp": "2026-01-01T00:00:00+00:00",
|
||||
},
|
||||
]
|
||||
idx = choose_keep_index(items, "by_reputation_quality_time", quality_comparison=qc)
|
||||
assert idx == 1
|
||||
|
||||
Reference in New Issue
Block a user