fix bug where overrides are applied after templates are processed
This commit is contained in:
+39
-1
@@ -1,6 +1,28 @@
|
||||
from dnd_item import types
|
||||
|
||||
|
||||
def test_AttributeMap():
|
||||
assert types.AttributeMap(attributes={'foo': True, 'bar': False}).foo is True
|
||||
|
||||
|
||||
def test_AttributeMap_nested():
|
||||
nested_dict = {'foo': {'bar': {'baz': True}, 'boz': False}}
|
||||
amap = types.AttributeMap.from_dict(nested_dict)
|
||||
assert amap.foo.bar.baz is True
|
||||
assert amap.foo.boz is False
|
||||
|
||||
|
||||
def test_AttributeMap_list():
|
||||
amap = types.AttributeMap(attributes={'foo': True, 'bar': False})
|
||||
assert list(amap.attributes.keys()) == ['foo', 'bar']
|
||||
|
||||
|
||||
def test_AttributeMap_mapping():
|
||||
amap = types.AttributeMap(attributes={'foo': True, 'bar': False})
|
||||
assert 'foo' in amap
|
||||
assert '{foo}, {bar}'.format(**amap) == 'True, False'
|
||||
|
||||
|
||||
def test_Item_attributes():
|
||||
assert types.Item.from_dict(dict(
|
||||
name='{length}ft. Pole',
|
||||
@@ -10,7 +32,7 @@ def test_Item_attributes():
|
||||
)).name == '10ft. Pole'
|
||||
|
||||
|
||||
def test_item_nested_attributes():
|
||||
def test_Item_nested_attributes():
|
||||
assert types.Item.from_dict(dict(
|
||||
name='{length}ft. Pole',
|
||||
length=10,
|
||||
@@ -23,3 +45,19 @@ def test_item_nested_attributes():
|
||||
owner='Jules Ultardottir',
|
||||
)
|
||||
)).description == 'Engraved. "Property of Jules Ultardottir!"'
|
||||
|
||||
|
||||
def test_Item_overrides():
|
||||
attrs = dict(
|
||||
name='{length}ft. Pole',
|
||||
length=10,
|
||||
properties=dict(
|
||||
broken=dict(
|
||||
description="The end of this 10ft. pole has been snapped off.",
|
||||
override_length=7
|
||||
),
|
||||
)
|
||||
)
|
||||
ten_foot_pole = types.Item.from_dict(attrs)
|
||||
assert ten_foot_pole.name == '7ft. Pole'
|
||||
assert ten_foot_pole.description == 'Broken. The end of this 10ft. pole has been snapped off.'
|
||||
|
||||
Reference in New Issue
Block a user