adding inventories

This commit is contained in:
evilchili
2024-07-28 13:55:19 -07:00
parent b68dda2b77
commit 3f45dbe9b9
6 changed files with 158 additions and 11 deletions
+6
View File
@@ -104,3 +104,9 @@ def bootstrap(db):
# persist all the records we've created
db.add_or_update([foo, bar])
@pytest.fixture
def carl(db, bootstrap):
tiefling = db.Ancestry.filter_by(name="tiefling").one()
carl = schema.Character(name="Carl", ancestry=tiefling)
return carl
+16
View File
@@ -0,0 +1,16 @@
from ttfrog.db.schema.item import Item, ItemType
def test_equipment_inventory(db, carl):
with db.transaction():
# trigger the creation of inventory mappings
db.add_or_update(carl)
# create an item
ten_foot_pole = Item(name="10ft. Pole", item_type=ItemType.ITEM, consumable=False)
db.add_or_update(ten_foot_pole)
# add the item to carl's inventory
carl.equipment.add(ten_foot_pole)
db.add_or_update(carl)
assert ten_foot_pole in carl.equipment