Skip to content

Commit 3f4653f

Browse files
S1M0N38claude
andcommitted
test(api): add shop booster structure validation test
Adds comprehensive test to validate shop_booster field structure including cards array, config object, and individual card properties. Verifies presence of Buffoon Pack and Jumbo Buffoon Pack in shop. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 48c4fd6 commit 3f4653f

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
@@ -834,6 +834,58 @@ def test_shop_vouchers_structure(self, tcp_client: socket.socket) -> None:
834834
assert "v_hone" in center_keys
835835
assert "Hone" in card_labels
836836

837+
def test_shop_booster_structure(self, tcp_client: socket.socket) -> None:
838+
"""Test that shop_booster contains expected structure when in shop state."""
839+
# Get current game state while in shop
840+
game_state = send_and_receive_api_message(tcp_client, "get_game_state", {})
841+
842+
# Verify we're in shop state
843+
assert game_state["state"] == State.SHOP.value
844+
845+
# Verify shop_booster exists and has correct structure
846+
assert "shop_booster" in game_state
847+
shop_booster = game_state["shop_booster"]
848+
849+
# Verify top-level structure
850+
assert "cards" in shop_booster
851+
assert "config" in shop_booster
852+
assert isinstance(shop_booster["cards"], list)
853+
assert isinstance(shop_booster["config"], dict)
854+
855+
# Verify config structure
856+
config = shop_booster["config"]
857+
assert "card_count" in config
858+
assert "card_limit" in config
859+
assert isinstance(config["card_count"], int)
860+
assert isinstance(config["card_limit"], int)
861+
862+
# Verify each booster card has required fields
863+
for card in shop_booster["cards"]:
864+
assert "ability" in card
865+
assert "config" in card
866+
assert "cost" in card
867+
assert "highlighted" in card
868+
assert "label" in card
869+
assert "sell_cost" in card
870+
871+
# Verify card config has center_key
872+
assert "center_key" in card["config"]
873+
assert isinstance(card["config"]["center_key"], str)
874+
875+
# Verify ability has set field with "Booster" value
876+
assert "set" in card["ability"]
877+
assert card["ability"]["set"] == "Booster"
878+
879+
# Verify we have expected booster packs from the reference game state
880+
center_keys = [card["config"]["center_key"] for card in shop_booster["cards"]]
881+
card_labels = [card["label"] for card in shop_booster["cards"]]
882+
883+
# Should contain Buffoon Pack and Jumbo Buffoon Pack based on reference
884+
assert "p_buffoon_normal_1" in center_keys
885+
assert "p_buffoon_jumbo_1" in center_keys
886+
assert "Buffoon Pack" in card_labels
887+
assert "Jumbo Buffoon Pack" in card_labels
888+
837889
def test_shop_buy_card(self, tcp_client: socket.socket) -> None:
838890
"""Test buying a card from shop."""
839891
# TODO: Implement test

0 commit comments

Comments
 (0)