refactor: extract character effect helpers
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
from core.basic.character.effect_apply import execute_effect, uppercase_attrs
|
||||
|
||||
|
||||
class Source:
|
||||
STR = 10
|
||||
|
||||
def __init__(self):
|
||||
self.INT = 20
|
||||
self.name = 'ignored'
|
||||
|
||||
|
||||
class Effects:
|
||||
def execture(self, key):
|
||||
if key != 'known':
|
||||
return None
|
||||
|
||||
def effect(target):
|
||||
target.append(key)
|
||||
|
||||
return effect
|
||||
|
||||
|
||||
def test_uppercase_attrs_returns_only_uppercase_instance_keys():
|
||||
assert uppercase_attrs(Source()) == {'INT': 20}
|
||||
|
||||
|
||||
def test_execute_effect_returns_false_for_missing_effect():
|
||||
assert execute_effect(Effects(), 'missing', []) is False
|
||||
|
||||
|
||||
def test_execute_effect_calls_existing_effect():
|
||||
target = []
|
||||
|
||||
assert execute_effect(Effects(), 'known', target) is True
|
||||
assert target == ['known']
|
||||
Reference in New Issue
Block a user