Add test for duplicate item persistence
This commit is contained in:
parent
8acfa5ea22
commit
05a739da74
1 changed files with 18 additions and 0 deletions
|
|
@ -139,6 +139,24 @@ def test_load_player_data_empty_inventory(db):
|
|||
assert data["inventory"] == []
|
||||
|
||||
|
||||
def test_save_load_duplicate_items(db, test_zone):
|
||||
"""Duplicate items (two rocks) round-trip correctly."""
|
||||
create_account("Dupes", "pass123")
|
||||
player = Player(
|
||||
name="Dupes",
|
||||
x=5,
|
||||
y=5,
|
||||
location=test_zone,
|
||||
)
|
||||
Thing(name="rock", location=player)
|
||||
Thing(name="rock", location=player)
|
||||
|
||||
save_player(player)
|
||||
data = load_player_data("Dupes")
|
||||
assert data is not None
|
||||
assert data["inventory"] == ["rock", "rock"]
|
||||
|
||||
|
||||
def test_load_player_data_migration_no_column(db):
|
||||
"""Old DB without inventory column returns empty list."""
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue