-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Implemented test for verifying h265 whitelisted groups - Improved readability of regex testing - Force merge (santiagosayshey)
- Loading branch information
1 parent
3f1d618
commit 9b505ba
Showing
3 changed files
with
186 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
from extract import get_custom_format, get_regex | ||
import re | ||
import sys | ||
|
||
# ANSI escape codes for colors | ||
GREEN = '\033[92m' | ||
RED = '\033[91m' | ||
RESET = '\033[0m' | ||
|
||
def h265(debug_level=0): | ||
# Get the custom formats for "h265" from both Radarr and Sonarr | ||
h265_radarr = get_custom_format("h265", "radarr", debug_level) | ||
h265_sonarr = get_custom_format("h265", "sonarr", debug_level) | ||
|
||
# Extract the regex values for verified groups | ||
h265_value_radarr = get_regex(h265_radarr, "verified groups", debug_level) | ||
h265_value_sonarr = get_regex(h265_sonarr, "verified groups", debug_level) | ||
|
||
# Replace the negative lookbehind with a negative lookahead | ||
h265_value_radarr = h265_value_radarr.replace("(?<=^|[\\s.-])", "(?:^|[\\s.-])") | ||
h265_value_sonarr = h265_value_sonarr.replace("(?<=^|[\\s.-])", "(?:^|[\\s.-])") | ||
|
||
if debug_level > 1: | ||
print(f"Testing with regex: {h265_value_radarr}") | ||
|
||
# Compare Radarr and Sonarr h265 regex values | ||
if h265_value_radarr != h265_value_sonarr: | ||
print("Test Failed: regex value not same.") | ||
print(f"Radarr regex: {h265_value_radarr}") | ||
print(f"Sonarr regex: {h265_value_sonarr}") | ||
sys.exit(1) | ||
|
||
radarr_good_matches = [ | ||
"The Batman (2022) (1080p HMAX WEB-DL H265 SDR DDP Atmos 5.1 English - HONE)", | ||
"King Richard (2021) (1080p HMAX WEB-DL H265 SDR DDP Atmos 5.1 English - HONE)", | ||
"The Survivor (2021) (1080p HMAX WEB-DL H265 SDR DD 5.1 English - HONE)", | ||
"Transformers (2007) (1080p HMAX WEB-DL H265 SDR DD 5.1 English - BLAZE)", | ||
"Significant Other (2022) (1080p AMZN WEB-DL H265 SDR DDP 5.1 English - Yoyo)", | ||
"The NeverEnding Story (1984) (1080p HMAX WEB-DL H265 SDR DD 5.1 English - SiGLA)", | ||
"Monster-in-Law (2005) (1080p HMAX WEB-DL H265 SDR DD 5.1 English - SiGLA)", | ||
"Rocky III (1982) (1080p AMZN WEB-DL H265 SDR DDP 5.1 English - AnoZu)", | ||
"Samaritan (2022) (1080p AMZN WEB-DL H265 SDR DDP 5.1 English - GRiMM)", | ||
"The Old Guard (2020) (1080p NF WEB-DL H265 SDR DDP Atmos 5.1 English - GRiMM)" | ||
] | ||
radarr_bad_matches = [ | ||
"The Tinder Swindler (2022) (1080p NF WEB-DL H265 SDR DDP Atmos 5.1 English - TEPES)", | ||
"The Greatest Lie Ever Sold: George Floyd and the Rise of BLM (2022) (1080p WEB-DL H265 SDR AAC 2.0 English - NOGROUP)", | ||
"Baccano! (2007) S01 (1080p BluRay H265 SDR OPUS 2.0 English - NOGROUP)", | ||
"Bhool Bhulaiyaa 2 (2022) (1080p NF WEB-DL H265 SDR DDP 5.1 Hindi - ElecTr0n)", | ||
"Ek Villain Returns (2022) (1080p NF WEB-DL H265 SDR DDP 5.1 Hindi - SKUI)" | ||
] | ||
sonarr_good_matches = [ | ||
"Minx (2022) S01 (1080p HMAX WEB-DL H265 SDR DD 5.1 English - HONE)", | ||
"We Own This City (2022) S01E01 (1080p HMAX WEB-DL H265 SDR DD 5.1 English - HONE)", | ||
"My Brilliant Friend (2018) S01 (1080p HMAX WEB-DL H265 SDR DD 5.1 Italian - HONE)", | ||
"The Goldbergs (2013) S09 (1080p HULU WEB-DL H265 SDR DDP 5.1 English - BLAZE)", | ||
"Atlanta (2016) S01 (1080p HULU WEB-DL H265 SDR DDP 5.1 English - Yoyo)", | ||
"Friday Night Lights (2006) S01 (1080p AMZN WEB-DL H265 SDR DDP 5.1 English - SiGMA)", | ||
"Defiance (2013) S03 (1080p AMZN WEB-DL H265 SDR DDP 5.1 English - SiGMA)", | ||
"Happy Valley (2014) S01 (1080p iP WEB-DL H265 SDR AAC 2.0 English - HECATE)", | ||
"Shaun the Sheep (2007) S05 (1080p iP WEB-DL H265 SDR AAC 2.0 English - HECATE)", | ||
"Skins (2007) S01 (1080p AMZN WEB-DL H265 SDR DDP 2.0 English - DarQ)", | ||
"Wheeler Dealers (2003) S17 (1080p AMZN WEB-DL H265 SDR DDP 2.0 English - DarQ)", | ||
"Supernatural (2005) S04 (1080p AMZN WEB-DL H265 SDR DDP 5.1 English - AnoZu)", | ||
"DC's Stargirl (2020) S01 (1080p AMZN WEB-DL H265 SDR DDP 5.1 English - YELLO)", | ||
"American Horror Story (2011) S12E01 (1080p HULU WEB-DL H265 SDR DDP 5.1 English - YELLO)" | ||
] | ||
sonarr_bad_matches = [ | ||
"House of the Dragon (2022) S00E24 (1080p HMAX WEB-DL H265 SDR DD 2.0 English - PbP)", | ||
"Daybreak (2019) S01 (1080p NF WEB-DL x265 SDR H265 DDP Atmos 5.1 English - t3nzin)", | ||
"Superjail! (2008) S03 (1080p AMZN WEB-DL H265 SDR DD 5.1 English - DiNGUS)" | ||
] | ||
|
||
|
||
failed_good_matches = [] | ||
failed_bad_matches = [] | ||
|
||
# Print Radarr Good Matches | ||
print("\nRadarr Releases:") | ||
print("----------------") | ||
print("Should Match:") | ||
for term in radarr_good_matches: | ||
if re.search(h265_value_radarr, term, re.IGNORECASE): | ||
print(f" - {term}: {GREEN}Passed{RESET}") | ||
else: | ||
failed_good_matches.append(("Radarr", term)) | ||
print(f" - {term}: {RED}Failed{RESET}") | ||
|
||
# Print Radarr Bad Matches | ||
print("\nShould NOT Match:") | ||
for term in radarr_bad_matches: | ||
if not re.search(h265_value_radarr, term, re.IGNORECASE): | ||
print(f" - {term}: {GREEN}Passed{RESET}") | ||
else: | ||
failed_bad_matches.append(("Radarr", term)) | ||
print(f" - {term}: {RED}Failed{RESET}") | ||
|
||
# Print Sonarr Good Matches | ||
print("\nSonarr Releases:") | ||
print("----------------") | ||
print("Should Match:") | ||
for term in sonarr_good_matches: | ||
if re.search(h265_value_sonarr, term, re.IGNORECASE): | ||
print(f" - {term}: {GREEN}Passed{RESET}") | ||
else: | ||
failed_good_matches.append(("Sonarr", term)) | ||
print(f" - {term}: {RED}Failed{RESET}") | ||
|
||
# Print Sonarr Bad Matches | ||
print("\nShould NOT Match:") | ||
for term in sonarr_bad_matches: | ||
if not re.search(h265_value_sonarr, term, re.IGNORECASE): | ||
print(f" - {term}: {GREEN}Passed{RESET}") | ||
else: | ||
failed_bad_matches.append(("Sonarr", term)) | ||
print(f" - {term}: {RED}Failed{RESET}") | ||
|
||
# Determine and print overall test result | ||
if not failed_good_matches and not failed_bad_matches: | ||
return True | ||
else: | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,41 @@ | ||
# run_tests.py | ||
import sys | ||
from roku import roku | ||
from h265verify import h265 | ||
# ... import other test functions | ||
|
||
# ANSI escape codes for colors | ||
BLUE = '\033[94m' | ||
GREEN = '\033[92m' | ||
RED = '\033[91m' | ||
YELLOW = '\033[93m' | ||
RESET = '\033[0m' | ||
|
||
def run_tests(): | ||
tests = [ | ||
("ROKU", roku), | ||
("h265 Verified Groups", h265) | ||
# ... add other test functions | ||
] | ||
|
||
failed_tests = [] | ||
for test_name, test_func in tests: | ||
print(f"Running test: {test_name}") | ||
test_result, failed_good_matches, failed_bad_matches = test_func(debug_level=0) | ||
print(f"{BLUE}=============================================={RESET}") | ||
print(f"{BLUE}Running test: {test_name}{RESET}") | ||
print(f"{BLUE}=============================================={RESET}\n") | ||
|
||
test_result = test_func(debug_level=1) | ||
|
||
if test_result: | ||
print(f"Test passed: {test_name}\n") | ||
print() | ||
print(f"{GREEN}=============================================={RESET}") | ||
print(f"{GREEN}Passed Test: {test_name}{RESET}") | ||
print(f"{GREEN}=============================================={RESET}\n") | ||
continue | ||
else: | ||
print(f"Test failed: {test_name}") | ||
if failed_bad_matches: | ||
print("The following terms should not have matched:") | ||
for platform, term in failed_bad_matches: | ||
print(f"- {platform}: {term}") | ||
if failed_good_matches: | ||
print("The following terms should have matched:") | ||
for platform, term in failed_good_matches: | ||
print(f"- {platform}: {term}") | ||
print() | ||
failed_tests.append((test_name, failed_good_matches, failed_bad_matches)) | ||
|
||
if failed_tests: | ||
print("Some tests failed!") | ||
sys.exit(1) | ||
else: | ||
print("All tests passed!") | ||
sys.exit(0) | ||
print(f"{RED}=============================================={RESET}") | ||
print(f"{RED}Failed Test: {test_name}{RESET}") | ||
print(f"{RED}=============================================={RESET}\n") | ||
sys.exit(1) | ||
|
||
if __name__ == "__main__": | ||
run_tests() | ||
run_tests() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters