Skip to content

Commit

Permalink
Merge pull request #71 from bbtufty/tests
Browse files Browse the repository at this point in the history
Add more tests
  • Loading branch information
bbtufty authored Dec 19, 2024
2 parents 5586d73 + e50776a commit 8d37641
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,4 @@ cython_debug/

# ROMSearch user-generated files
saved_config.json
*.log.*
11 changes: 11 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
0.1.2 (Unreleased)
==================

Fixes
-----

General
~~~~~~~

- Add more tests

0.1.1 (2024-12-18)
==================

Expand Down
83 changes: 81 additions & 2 deletions tests/tests_romchooser.py
Original file line number Diff line number Diff line change
@@ -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"""

Expand All @@ -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)"]
6 changes: 4 additions & 2 deletions tests/tests_romparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 8d37641

Please sign in to comment.