diff --git a/fileflows/tests/test_sonarr_import_safety.py b/fileflows/tests/test_sonarr_import_safety.py index 7c45df6..26f6308 100644 --- a/fileflows/tests/test_sonarr_import_safety.py +++ b/fileflows/tests/test_sonarr_import_safety.py @@ -77,6 +77,69 @@ def run_script(scenario): class SonarrImportSafetyTests(unittest.TestCase): + def test_fhd_scope_does_not_match_uhd_sibling_prefix(self): + exact = ( + "/tdarr/converted/serien4k/Marshals.2026.S01.GERMAN.DUBBED/" + "Marshals.2026.S01E05.GERMAN.DUBBED.mkv" + ) + result = run_script( + { + "releaseTitle": "Marshals.2026.S01E05.GERMAN.DUBBED", + "exactPath": exact, + "scopeRoot": "/tdarr/converted/serien", + } + ) + + self.assertEqual(result["result"], 1) + self.assertEqual(result["calls"], []) + + def test_season_pack_history_uses_exact_episode_filename_for_parse(self): + pack = "Marshals.2026.S01.GERMAN.DUBBED.DL.2160p.WEB.H265-TSCC" + episode = "Marshals.2026.S01E05.GERMAN.DUBBED.DL.2160p.WEB.H265-TSCC" + exact = f"/tdarr/converted/serien4k/{pack}/{episode}.mkv" + queue_records = [ + {"title": pack, "seriesId": 600, "episodeId": 37500 + number} + for number in range(1, 14) + ] + history_records = [ + { + "sourceTitle": pack, + "seriesId": 600, + "episodeId": 37500 + number, + "eventType": "grabbed", + } + for number in range(1, 14) + ] + result = run_script( + { + "releaseTitle": episode, + "exactPath": exact, + "scopeRoot": "/tdarr/converted/serien4k", + "queueResponse": {"records": queue_records}, + "historyResponse": {"records": history_records}, + "parseResponse": { + "series": {"id": 600, "title": "Marshals"}, + "episodes": [{"id": 37505}], + }, + "candidates": [ + { + "path": exact, + "quality": {"quality": {"id": 19, "name": "WEBDL-2160p"}}, + "languages": [{"id": 4, "name": "German"}], + } + ], + } + ) + + self.assertEqual(result["result"], 1) + command = next(call for call in result["calls"] if call["type"] == "command") + self.assertEqual(command["body"]["files"][0]["episodeIds"], [37505]) + parse_call = next( + call for call in result["calls"] + if call["type"] == "fetch" and call["endpoint"] == "parse" + ) + self.assertIn("s01e05", parse_call["query"].lower()) + def test_percent_title_matches_queue_and_imports_exact_episode_file(self): source_title = ( "100%.Wolf.S01E01.Die.Aufnahmeprufung.German.1080p."