Initial snapshot before step 10 package split
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
import importlib.util
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
SPEC = importlib.util.spec_from_file_location("rcjav_rules", ROOT / "rc-jav.py")
|
||||
RCJAV = importlib.util.module_from_spec(SPEC)
|
||||
sys.modules[SPEC.name] = RCJAV
|
||||
SPEC.loader.exec_module(RCJAV)
|
||||
|
||||
|
||||
def entry(path, size=1_000, jav_id="TEST-001"):
|
||||
return RCJAV.FileEntry(
|
||||
source="Target",
|
||||
remote="cq:JAV",
|
||||
path=path,
|
||||
size=size,
|
||||
mod_time="",
|
||||
jav_id=jav_id,
|
||||
)
|
||||
|
||||
|
||||
class IdRuleTests(unittest.TestCase):
|
||||
def test_builtin_multipart_shapes_keep_parts_distinct(self):
|
||||
expected = {
|
||||
"KV-118 - Aiba Reika_PART1.mp4": "KV-118#part1",
|
||||
"KV-118_A.mp4": "KV-118#part1",
|
||||
"OFJE-195-7 [480p].mp4": "OFJE-195#part7",
|
||||
"ABC-027.mp4": "ABC-027",
|
||||
}
|
||||
for name, jav_id in expected.items():
|
||||
with self.subTest(name=name):
|
||||
self.assertEqual(RCJAV.extract_id(name), jav_id)
|
||||
|
||||
def test_multipart_files_do_not_form_base_duplicate_group(self):
|
||||
files = [
|
||||
entry("KV-118 - Aiba Reika_PART1.mp4", jav_id="KV-118"),
|
||||
entry("KV-118 - Aiba Reika_PART2.mp4", jav_id="KV-118"),
|
||||
entry("KV-118 - Aiba Reika_PART3.mp4", jav_id="KV-118"),
|
||||
]
|
||||
self.assertEqual(RCJAV.find_dupes(files), {})
|
||||
|
||||
def test_large_same_id_group_gets_manual_review_risk(self):
|
||||
files = [
|
||||
entry("TEST-001 direct.mp4"),
|
||||
entry("TEST-001 edit.mp4"),
|
||||
entry("TEST-001 mirror.mp4"),
|
||||
]
|
||||
risks = RCJAV.describe_dupe_risks("TEST-001", files)
|
||||
self.assertIn("large_same_id_group", {risk["code"] for risk in risks})
|
||||
|
||||
|
||||
class KeepRankingTests(unittest.TestCase):
|
||||
def test_vip_folder_beats_larger_non_vip_copy(self):
|
||||
keep, reason = RCJAV.decide_keep_with_reason([
|
||||
entry("ClearJAV/TEST-001.mp4", size=2_000),
|
||||
entry("Other/TEST-001 [1080p].mkv", size=9_000),
|
||||
])
|
||||
self.assertEqual(keep.path, "ClearJAV/TEST-001.mp4")
|
||||
self.assertEqual(reason["code"], "vip_folder")
|
||||
|
||||
def test_ts_loses_to_non_ts_even_when_larger(self):
|
||||
keep, reason = RCJAV.decide_keep_with_reason([
|
||||
entry("Other/TEST-001.ts", size=9_000),
|
||||
entry("Other/TEST-001.mp4", size=8_000),
|
||||
])
|
||||
self.assertEqual(keep.path, "Other/TEST-001.mp4")
|
||||
self.assertEqual(reason["code"], "container")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user