Skip to content

Commit a20ab63

Browse files
S1M0N38claude
andcommitted
test(api): add shop jokers structure validation test
Add comprehensive test to verify shop_jokers field structure and content when in shop state, including validation of cards and configuration. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ad062bb commit a20ab63

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

tests/lua/test_api_functions.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,65 @@ def test_shop_invalid_action_error(self, tcp_client: socket.socket) -> None:
728728
ErrorCode.INVALID_ACTION.value,
729729
)
730730

731+
def test_shop_jokers_structure(self, tcp_client: socket.socket) -> None:
732+
"""Test that shop_jokers contains expected structure when in shop state."""
733+
# Get current game state while in shop
734+
game_state = send_and_receive_api_message(tcp_client, "get_game_state", {})
735+
736+
# Verify we're in shop state
737+
assert game_state["state"] == State.SHOP.value
738+
739+
# Verify shop_jokers exists and has correct structure
740+
assert "shop_jokers" in game_state
741+
shop_jokers = game_state["shop_jokers"]
742+
743+
# Verify top-level structure
744+
assert "cards" in shop_jokers
745+
assert "config" in shop_jokers
746+
assert isinstance(shop_jokers["cards"], list)
747+
assert isinstance(shop_jokers["config"], dict)
748+
749+
# Verify config structure
750+
config = shop_jokers["config"]
751+
assert "card_count" in config
752+
assert "card_limit" in config
753+
assert isinstance(config["card_count"], int)
754+
assert isinstance(config["card_limit"], int)
755+
756+
# Verify each card has required fields
757+
for card in shop_jokers["cards"]:
758+
assert "ability" in card
759+
assert "config" in card
760+
assert "cost" in card
761+
assert "debuff" in card
762+
assert "facing" in card
763+
assert "highlighted" in card
764+
assert "label" in card
765+
assert "sell_cost" in card
766+
767+
# Verify card config has card_key
768+
assert "card_key" in card["config"]
769+
assert isinstance(card["config"]["card_key"], str)
770+
771+
# Verify ability has set field
772+
assert "set" in card["ability"]
773+
assert isinstance(card["ability"]["set"], str)
774+
775+
# Verify we have expected cards from the reference game state
776+
card_keys = [card["config"]["card_key"] for card in shop_jokers["cards"]]
777+
card_labels = [card["label"] for card in shop_jokers["cards"]]
778+
779+
# Should contain Burglar joker and Jupiter planet card based on reference
780+
assert "j_burglar" in card_keys
781+
assert "c_jupiter" in card_keys
782+
assert "Burglar" in card_labels
783+
assert "Jupiter" in card_labels
784+
785+
def test_shop_buy_card(self, tcp_client: socket.socket) -> None:
786+
"""Test buying a card from shop."""
787+
# TODO: Implement test
788+
...
789+
731790
def test_shop_invalid_state_error(self, tcp_client: socket.socket) -> None:
732791
"""Test shop returns error when not in shop state."""
733792
# Go to menu first to ensure we're not in shop state

0 commit comments

Comments
 (0)