adding tests and helper UX to schema

This commit is contained in:
evilchili
2024-03-26 21:58:04 -07:00
parent 78115023bb
commit dbb9461b7a
4 changed files with 79 additions and 9 deletions
+25
View File
@@ -1,6 +1,7 @@
{
"CharacterClass": [
{
"id": 1,
"name": "fighter",
"hit_dice": "1d10",
"hit_dice_stat": "CON",
@@ -9,6 +10,7 @@
"skills": ["Acrobatics", "Animal Handling", "Athletics", "History", "Insight", "Intimidation", "Perception", "Survival"]
},
{
"id": 2,
"name": "rogue",
"hit_dice": "1d8",
"hit_dice_stat": "DEX",
@@ -16,5 +18,28 @@
"saving_throws": ["DEX", "INT"],
"skills": ["Acrobatics", "Athletics", "Deception", "Insight", "Intimidation", "Investigation", "Perception", "Performance", "Persuasion", "Sleight of Hand", "Stealth"]
}
],
"ClassAttribute": [
{
"id": 1,
"name": "Fighting Style"
}
],
"ClassAttributeMap": [
{
"class_attribute_id": 1,
"character_class_id": 1,
"level": 2
}
],
"ClassAttributeOption": [
{
"attribute_id": 1,
"name": "Archery"
},
{
"attribute_id": 1,
"name": "Battlemaster"
}
]
}
+15 -4
View File
@@ -26,16 +26,26 @@ def test_create_character(db, classes, ancestries):
db.add(char)
assert char.levels == {"fighter": 1}
assert char.level == 1
assert char.class_attributes == []
assert char.class_attributes == {}
# 'fighting style' is available, but not at this level
fighting_style = char.classes["fighter"].attributes_by_level[2]["Fighting Style"]
assert char.add_class_attribute(fighting_style, fighting_style.options[0]) is False
db.add(char)
assert char.class_attributes == {}
# level up
char.add_class(classes["fighter"], level=2)
db.add(char)
assert char.levels == {"fighter": 2}
assert char.level == 2
assert char.class_attributes == []
# multiclass
# Assign the fighting style
assert char.add_class_attribute(fighting_style, fighting_style.options[0])
db.add(char)
assert char.class_attributes[fighting_style.name] == fighting_style.options[0]
# classes
char.add_class(classes["rogue"], level=1)
db.add(char)
assert char.level == 3
@@ -51,6 +61,7 @@ def test_create_character(db, classes, ancestries):
char.remove_class(classes["fighter"])
db.add(char)
# ensure we're not persisting any orphan records in the map table
# ensure we're not persisting any orphan records in the map tables
dump = db.dump()
assert dump["class_map"] == []
assert dump["character_class_attribute_map"] == []