Prepared package for adding GM sheets.

- Improved test coverage in ``make_sheets.py``.
- Refactor file loading to make it more flexible.
- Added a stub ``gm.py`` example.
This commit is contained in:
Mark Wolfman
2021-06-01 22:51:10 -05:00
parent bb3a40ed0e
commit 3b8dbc0566
7 changed files with 116 additions and 19 deletions
+56 -3
View File
@@ -1,9 +1,8 @@
import unittest
import os
from pathlib import Path
from dungeonsheets import make_sheets, character
from dungeonsheets.fill_pdf_template import create_character_pdf_template, create_spells_pdf_template
from dungeonsheets.classes import monk
EG_DIR = os.path.abspath(os.path.join(os.path.split(__file__)[0], "../examples/"))
@@ -25,5 +24,59 @@ class PdfOutputTestCase(unittest.TestCase):
# self.assertFalse(os.path.exists(pdf_name), f'{pdf_name} already exists.')
char = character.Character(name="Clara")
char.saving_throw_proficiencies = ["strength"]
make_sheets.create_character_pdf_template(character=char, basename=self.basename)
make_sheets.create_character_pdf_template(
character=char, basename=self.basename
)
self.assertTrue(os.path.exists(pdf_name), f"{pdf_name} not created.")
class TexCreatorTestCase(unittest.TestCase):
"""Test various helper functions for creating TeX from a character."""
def new_character(self):
char = character.Character(
classes=["Monk", "Druid", "Artificer"],
levels=[1, 1, 1],
subclasses=["way of the open hand", None, None],
magic_items=["cloak of protection"],
spells=["invisibility"],
wild_shapes=["crocodile"],
infusions=["boots of the winding path"]
)
return char
def test_create_subclasses_tex(self):
char = self.new_character()
tex = make_sheets.create_subclasses_tex(character=char)
self.assertIn(r"\section*{Subclasses}", tex)
self.assertIn(r"\subsection*{Way of the Open Hand}", tex)
def test_create_features_tex(self):
char = self.new_character()
tex = make_sheets.create_features_tex(character=char)
self.assertIn(r"\section*{Features}", tex)
self.assertIn(r"\subsection*{Martial Arts}", tex)
def test_create_magic_items_tex(self):
char = self.new_character()
tex = make_sheets.create_magic_items_tex(character=char)
self.assertIn(r"\section*{Magic Items}", tex)
self.assertIn(r"\subsection*{Cloak of Protection}", tex)
def test_create_spellbook_tex(self):
char = self.new_character()
tex = make_sheets.create_spellbook_tex(character=char)
self.assertIn(r"\section*{Spells}", tex)
self.assertIn(r"\section*{Invisibility}", tex)
def test_create_infusions_tex(self):
char = self.new_character()
tex = make_sheets.create_infusions_tex(character=char)
self.assertIn(r"\section*{Infusions}", tex)
self.assertIn(r"\subsection*{Boots of the Winding Path}", tex)
def test_create_druid_shapes_tex(self):
char = self.new_character()
tex = make_sheets.create_druid_shapes_tex(character=char)
self.assertIn(r"\section*{Known Beasts}", tex)
self.assertIn(r"\section*{Crocodile}", tex)