Skip to content

Commit

Permalink
Add tests for correct and incorrect console handling in retro forwarders
Browse files Browse the repository at this point in the history
- Introduced separate forwarder IDs for 3DS (`FORWARDER_ID_3DS`) and PSP (`FORWARDER_ID_PSP`) to test console-specific requests.
- Added tests to verify correct responses when requesting retro forwarders for the correct console (`test_nx_retro_correct_console`).
- Implemented a test to check for a 400 error when an incorrect console is specified (`test_nx_retro_wrong_console`).
  • Loading branch information
Lenochxd committed Sep 8, 2024
1 parent 6c4f640 commit c5315c1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
7 changes: 7 additions & 0 deletions tests/test-db/retro/psp/0510300000ab0000.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "0510300000ab0000",
"name": "Sweet Fuse - At Your Side [PSP]",
"size": 692015749,
"releaseDate": 20120614,
"description": "Sweet Fuse: At Your Side stars Saki Inafune, niece to legendary game developer Keiji Inafune. Saki\u2019s famous uncle opens an amusement park and Saki attends the opening ceremony, but things really heat up when Count Hogstein\u2014a malevolent pig\u2014takes over the park, and holds everyone hostage. Saki, along with seven sexy men, decides to enter Count Hogstein\u2019s deadly game in order to save her uncle and the other hostages. Will she be able to solve the complex puzzles that Count Hogstein and his merry henchmen have in store? And most importantly, which steamy bachelor will Saki choose?<br/><br/> Software subject to license (us.playstation.com/softwarelicense).\u00a0 Online activity subject to Terms of Services and User Agreement (www.sonyenteretainmentnetwork.com/terms-of-service). One time license fee entitles play on up 3 portable PlayStation\u00ae systems activated by this account.<br/><br/>"
}
17 changes: 14 additions & 3 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
DLC_ID = "0100A0C00D847001"
UPDATE_ID = "0100997014004800"
FORWARDER_CONSOLE = "3Ds"
FORWARDER_ID = "0510800001e30000"
FORWARDER_ID_3DS = "0510800001e30000"
FORWARDER_ID_PSP = "0510300000ab0000"

def test_uptime():
response = client.get("/uptime")
Expand Down Expand Up @@ -90,17 +91,27 @@ def test_get_nx_update():
assert response.json().get("type") == "update"

def test_nx_retro_endpoint():
response = client.get(f"/nx/retro/{FORWARDER_ID}")
response = client.get(f"/nx/retro/{FORWARDER_ID_3DS}")
assert response.status_code == 200
assert response.json().get("type") == "retro"
assert response.json().get("console") == "3ds"

def test_nx_forwarder_console_endpoint():
response = client.get(f"/nx/forwarder/{FORWARDER_CONSOLE}/{FORWARDER_ID}")
response = client.get(f"/nx/forwarder/{FORWARDER_CONSOLE}/{FORWARDER_ID_3DS}")
assert response.status_code == 200
assert response.json().get("type") == "retro"
assert response.json().get("console") == "3ds"

def test_nx_retro_correct_console():
response = client.get(f"/nx/retro/psp/{FORWARDER_ID_PSP}")
assert response.status_code == 200
assert response.json().get("type") == "retro"
assert response.json().get("console") == "psp"

def test_nx_retro_wrong_console():
response = client.get(f"/nx/retro/psp/{FORWARDER_ID_3DS}")
assert response.status_code == 400

def test_get_nonexistent_game():
response = client.get("/nx/jadeisbetterthanyou")
assert response.status_code == 404
Expand Down

0 comments on commit c5315c1

Please sign in to comment.