Skip to content

Commit

Permalink
Add pytest tests for forwarder and retro endpoints
Browse files Browse the repository at this point in the history
- Added test cases for the `/nx/forwarder/{console}/{tid}` and `/nx/retro/{tid}` endpoints to validate retro forwarder functionality.
- Included a new forwarder TID for the 3DS console in the test database to ensure accurate testing.
- Enhanced test coverage to verify correct responses and error handling for forwarders and unsupported platforms.
  • Loading branch information
Lenochxd committed Sep 8, 2024
1 parent 1cc39e8 commit 6c4f640
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
7 changes: 7 additions & 0 deletions tests/test-db/retro/3ds/0510800001e30000.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"id": "0510800001e30000",
"name": "Pet Zombies [3DS]",
"size": 81399807,
"releaseDate": 20111018,
"description": "<p>\n Pet Zombies for Nintendo 3DS lets you reanimate your very own \n customizable zombies that you can play with, care for, or torment in a \n variety of environments where they can shamble, shuffle and lurch. Bond \n with your zombie by providing it food, toys and interaction, but be \n careful; if you neglect your zombie, you may find yourself minus a \n finger, or...a brain!\n </p><p>\n Features\n </p><p>\n \u2022 Nurture your zombie with severed arm chew toys, brains-in-a-ball, and \n more!<br/>\u2022 Punish your zombie with torches, shock collars, and more!<br/>\u2022 \n Play games with your pet to buy fun new items in the shop.\n </p>"
}
20 changes: 17 additions & 3 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
GAME_ID = "0100A0D004FB0000"
DLC_ID = "0100A0C00D847001"
UPDATE_ID = "0100997014004800"
FORWARDER_CONSOLE = "3Ds"
FORWARDER_ID = "0510800001e30000"

def test_uptime():
response = client.get("/uptime")
Expand Down Expand Up @@ -87,10 +89,22 @@ def test_get_nx_update():
assert response.status_code == 200
assert response.json().get("type") == "update"

def test_get_unsupported_platform():
response = client.get(f"/ps5/{GAME_ID}")
assert response.status_code == 404 # notice how there are no games on ps5
def test_nx_retro_endpoint():
response = client.get(f"/nx/retro/{FORWARDER_ID}")
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}")
assert response.status_code == 200
assert response.json().get("type") == "retro"
assert response.json().get("console") == "3ds"

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

def test_get_unsupported_platform():
response = client.get(f"/ps5/{GAME_ID}")
assert response.status_code == 404 # notice how there are no games on ps5

0 comments on commit 6c4f640

Please sign in to comment.