Skip to content

Commit 0c72069

Browse files
S1M0N38claude
andcommitted
test(api): add shop vouchers structure validation test
Adds comprehensive test for shop_vouchers field structure when in shop state, validating: - Top-level cards and config structure - Config card_count and card_limit fields - Individual voucher card required fields - Voucher-specific center_key usage - Ability set field verification Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b998062 commit 0c72069

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

tests/lua/test_api_functions.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,58 @@ def test_shop_jokers_structure(self, tcp_client: socket.socket) -> None:
782782
assert "Burglar" in card_labels
783783
assert "Jupiter" in card_labels
784784

785+
def test_shop_vouchers_structure(self, tcp_client: socket.socket) -> None:
786+
"""Test that shop_vouchers contains expected structure when in shop state."""
787+
# Get current game state while in shop
788+
game_state = send_and_receive_api_message(tcp_client, "get_game_state", {})
789+
790+
# Verify we're in shop state
791+
assert game_state["state"] == State.SHOP.value
792+
793+
# Verify shop_vouchers exists and has correct structure
794+
assert "shop_vouchers" in game_state
795+
shop_vouchers = game_state["shop_vouchers"]
796+
797+
# Verify top-level structure
798+
assert "cards" in shop_vouchers
799+
assert "config" in shop_vouchers
800+
assert isinstance(shop_vouchers["cards"], list)
801+
assert isinstance(shop_vouchers["config"], dict)
802+
803+
# Verify config structure
804+
config = shop_vouchers["config"]
805+
assert "card_count" in config
806+
assert "card_limit" in config
807+
assert isinstance(config["card_count"], int)
808+
assert isinstance(config["card_limit"], int)
809+
810+
# Verify each voucher card has required fields
811+
for card in shop_vouchers["cards"]:
812+
assert "ability" in card
813+
assert "config" in card
814+
assert "cost" in card
815+
assert "debuff" in card
816+
assert "facing" in card
817+
assert "highlighted" in card
818+
assert "label" in card
819+
assert "sell_cost" in card
820+
821+
# Verify card config has center_key (vouchers use center_key not card_key)
822+
assert "center_key" in card["config"]
823+
assert isinstance(card["config"]["center_key"], str)
824+
825+
# Verify ability has set field with "Voucher" value
826+
assert "set" in card["ability"]
827+
assert card["ability"]["set"] == "Voucher"
828+
829+
# Verify we have expected voucher from the reference game state
830+
center_keys = [card["config"]["center_key"] for card in shop_vouchers["cards"]]
831+
card_labels = [card["label"] for card in shop_vouchers["cards"]]
832+
833+
# Should contain Hone voucher based on reference
834+
assert "v_hone" in center_keys
835+
assert "Hone" in card_labels
836+
785837
def test_shop_buy_card(self, tcp_client: socket.socket) -> None:
786838
"""Test buying a card from shop."""
787839
# TODO: Implement test

0 commit comments

Comments
 (0)