From 84cece0b9133f9e7045ac72cdbbc4df78da208ca Mon Sep 17 00:00:00 2001 From: bbtufty Date: Thu, 19 Dec 2024 07:46:43 +0000 Subject: [PATCH] Add more tests - Add tests for regions, languages etc. --- .gitignore | 1 + CHANGES.rst | 8 ++++ tests/tests_romchooser.py | 83 ++++++++++++++++++++++++++++++++++++++- tests/tests_romparser.py | 6 ++- 4 files changed, 94 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 6666f8e..e7d914c 100644 --- a/.gitignore +++ b/.gitignore @@ -161,3 +161,4 @@ cython_debug/ # ROMSearch user-generated files saved_config.json +*.log.* diff --git a/CHANGES.rst b/CHANGES.rst index 4e94039..6402faf 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,3 +1,11 @@ +0.1.2 (Unreleased) +================== + +General +~~~~~~~ + +- Add more tests + 0.1.1 (2024-12-18) ================== diff --git a/tests/tests_romchooser.py b/tests/tests_romchooser.py index 285797a..b258559 100644 --- a/tests/tests_romchooser.py +++ b/tests/tests_romchooser.py @@ -1,8 +1,60 @@ from romsearch import ROMParser, ROMChooser -TEST_NAME = "Example Game (USA) (En,De,Fr)" +TEST_NAME = "Example Game" +def test_romchooser_region(): + """Put a number of regions through and check ROMChooser gets the right one""" + + test_case = { + f"{TEST_NAME} (Europe)": {"priority": 1}, + f"{TEST_NAME} (USA)": {"priority": 1}, + } + + rp = ROMParser( + config_file="test_config.yml", + platform="Nintendo - Super Nintendo Entertainment System", + game="Example Game", + ) + rom_dict = rp.run(test_case) + + rc = ROMChooser( + config_file="test_config.yml", + platform="Nintendo - Super Nintendo Entertainment System", + game="Example Game", + ) + rom_dict = rc.run(rom_dict) + + roms_found = [r for r in rom_dict] + + assert roms_found == ["Example Game (USA)"] + +def test_romchooser_language(): + """Put a number of languages through and check ROMChooser gets the right one""" + + test_case = { + f"{TEST_NAME} (En,De)": {"priority": 1}, + f"{TEST_NAME} (Ja)": {"priority": 1}, + } + + rp = ROMParser( + config_file="test_config.yml", + platform="Nintendo - Super Nintendo Entertainment System", + game="Example Game", + ) + rom_dict = rp.run(test_case) + + rc = ROMChooser( + config_file="test_config.yml", + platform="Nintendo - Super Nintendo Entertainment System", + game="Example Game", + ) + rom_dict = rc.run(rom_dict) + + roms_found = [r for r in rom_dict] + + assert roms_found == ["Example Game (En,De)"] + def test_romchooser_version(): """Put a number of versions through and check ROMChooser gets the right one""" @@ -28,4 +80,31 @@ def test_romchooser_version(): roms_found = [r for r in rom_dict] - assert roms_found == ["Example Game (USA) (En,De,Fr) (v2.00)"] + assert roms_found == ["Example Game (v2.00)"] + +def test_romchooser_priority(): + """Put a number of priorities through and check ROMChooser gets the right one""" + + test_case = { + TEST_NAME: {"priority": 3}, + f"{TEST_NAME} (Higher Priority)": {"priority": 2}, + f"{TEST_NAME} (Highest Priority)": {"priority": 1}, + } + + rp = ROMParser( + config_file="test_config.yml", + platform="Nintendo - Super Nintendo Entertainment System", + game="Example Game", + ) + rom_dict = rp.run(test_case) + + rc = ROMChooser( + config_file="test_config.yml", + platform="Nintendo - Super Nintendo Entertainment System", + game="Example Game", + ) + rom_dict = rc.run(rom_dict) + + roms_found = [r for r in rom_dict] + + assert roms_found == ["Example Game (Highest Priority)"] diff --git a/tests/tests_romparser.py b/tests/tests_romparser.py index e13e173..4b4bb99 100644 --- a/tests/tests_romparser.py +++ b/tests/tests_romparser.py @@ -23,9 +23,11 @@ def test_romparser_regions(): def test_romparser_languages(): """Put a filename into ROMParser and check it returns the right languages""" - expected_languages = ["English", "French", "German", "Italian", "Spanish"] + expected_languages = ["English", "French", "German", "Spanish"] - test_case = {TEST_NAME: {"priority": 1}} + test_case = {TEST_NAME: {"priority": 1, + "title_pos": 1} + } rp = ROMParser( config_file="test_config.yml",