mirror of
https://github.com/Threnklyn/dungeon-sheets.git
synced 2026-06-03 19:38:30 +02:00
Ran flake8 and black against tests.
This commit is contained in:
+57
-22
@@ -6,21 +6,22 @@ import types
|
||||
from dungeonsheets.readers import read_character_file
|
||||
|
||||
EG_DIR = (Path(__file__).parent.parent / "examples").resolve()
|
||||
CHAR_PYTHON_FILE = EG_DIR / 'rogue1.py'
|
||||
CHAR_JSON_FILE = EG_DIR / 'barbarian3.json'
|
||||
SPELLCASTER_JSON_FILE = EG_DIR / 'artificer2.json'
|
||||
CHAR_PYTHON_FILE = EG_DIR / "rogue1.py"
|
||||
CHAR_JSON_FILE = EG_DIR / "barbarian3.json"
|
||||
SPELLCASTER_JSON_FILE = EG_DIR / "artificer2.json"
|
||||
|
||||
|
||||
class PythonReaderTests(unittest.TestCase):
|
||||
def test_load_python_file(self):
|
||||
charfile = CHAR_PYTHON_FILE
|
||||
result = read_character_file(charfile)
|
||||
self.assertEqual(result['strength'], 10)
|
||||
self.assertEqual(result["strength"], 10)
|
||||
|
||||
|
||||
class JSONReaderTests(unittest.TestCase):
|
||||
class JSONReaderTests(unittest.TestCase):
|
||||
def test_load_json_file(self):
|
||||
charfile = CHAR_JSON_FILE
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
with warnings.catch_warnings(record=True):
|
||||
result = read_character_file(charfile)
|
||||
expected_data = dict(
|
||||
name="Ulthar Jenkins",
|
||||
@@ -35,9 +36,22 @@ class JSONReaderTests(unittest.TestCase):
|
||||
constitution=19,
|
||||
intelligence=8,
|
||||
hp_max=32,
|
||||
skill_proficiencies=["athletics", "survival",],
|
||||
weapon_proficiencies=["simple weapons", "martial weapons", "battleaxe", "handaxe", "light hammer", "warhammer", "unarmed strike",],
|
||||
_proficiencies_text=["Brewer's Supplies",],
|
||||
skill_proficiencies=[
|
||||
"athletics",
|
||||
"survival",
|
||||
],
|
||||
weapon_proficiencies=[
|
||||
"simple weapons",
|
||||
"martial weapons",
|
||||
"battleaxe",
|
||||
"handaxe",
|
||||
"light hammer",
|
||||
"warhammer",
|
||||
"unarmed strike",
|
||||
],
|
||||
_proficiencies_text=[
|
||||
"Brewer's Supplies",
|
||||
],
|
||||
languages="common, dwarvish",
|
||||
cp=26,
|
||||
sp=55,
|
||||
@@ -48,13 +62,17 @@ class JSONReaderTests(unittest.TestCase):
|
||||
magic_items=(),
|
||||
armor="",
|
||||
shield="",
|
||||
personality_traits="Can easily dismember a body\n\nKnow fight battle tactics",
|
||||
personality_traits=(
|
||||
"Can easily dismember a body\n\nKnow fight battle tactics"
|
||||
),
|
||||
ideals="Vengence",
|
||||
bonds="friends and adventurers.",
|
||||
flaws="Bloodthirsty and wants to solve every problem by murder",
|
||||
equipment=("warhammer, handaxe, explorer's pack, javelin (4), backpack, "
|
||||
"bedroll, mess kit, tinderbox, torch (10), rations (10), "
|
||||
"waterskin, hempen rope"),
|
||||
equipment=(
|
||||
"warhammer, handaxe, explorer's pack, javelin (4), backpack, "
|
||||
"bedroll, mess kit, tinderbox, torch (10), rations (10), "
|
||||
"waterskin, hempen rope"
|
||||
),
|
||||
attacks_and_spellcasting="",
|
||||
spells_prepared=[],
|
||||
spells=[],
|
||||
@@ -65,19 +83,36 @@ class JSONReaderTests(unittest.TestCase):
|
||||
if isinstance(this_result, types.GeneratorType):
|
||||
this_result = list(this_result)
|
||||
self.assertEqual(this_result, val, key)
|
||||
|
||||
|
||||
def test_load_json_spells(self):
|
||||
charfile = SPELLCASTER_JSON_FILE
|
||||
with warnings.catch_warnings(record=True) as w:
|
||||
with warnings.catch_warnings(record=True):
|
||||
result = read_character_file(charfile)
|
||||
expected_data = dict(
|
||||
spells_prepared=["cure wounds",],
|
||||
spells=["spare the dying", "fire bolt", "absorb elements",
|
||||
"alarm", "catapult", "cure wounds", "detect magic",
|
||||
"disguise self", "expeditious retreat", "faerie fire",
|
||||
"false life", "feather fall", "grease", "identify",
|
||||
"jump", "longstrider", "purify food and drink",
|
||||
"sanctuary", "snare",],
|
||||
spells_prepared=[
|
||||
"cure wounds",
|
||||
],
|
||||
spells=[
|
||||
"spare the dying",
|
||||
"fire bolt",
|
||||
"absorb elements",
|
||||
"alarm",
|
||||
"catapult",
|
||||
"cure wounds",
|
||||
"detect magic",
|
||||
"disguise self",
|
||||
"expeditious retreat",
|
||||
"faerie fire",
|
||||
"false life",
|
||||
"feather fall",
|
||||
"grease",
|
||||
"identify",
|
||||
"jump",
|
||||
"longstrider",
|
||||
"purify food and drink",
|
||||
"sanctuary",
|
||||
"snare",
|
||||
],
|
||||
)
|
||||
for key, val in expected_data.items():
|
||||
this_result = result[key]
|
||||
|
||||
Reference in New Issue
Block a user