Files
dungeon-sheets/tests/test_make_sheets.py
T
Mark Wolfman 30369ce1d4 Ran flake8 and black linters, and other cleanup-related fixes.
Project now passes flake8 and black linter (also including more rst
cleanup). Moved latex related things to dedicated ``latex.py`` module,
and removed the ``makesheets -dF`` call from travis.
2021-04-16 11:10:17 -05:00

39 lines
1.3 KiB
Python

import unittest
import os
from pathlib import Path
import subprocess
from dungeonsheets import make_sheets, character
EG_DIR = os.path.abspath(os.path.join(os.path.split(__file__)[0], '../examples/'))
CHARFILE = os.path.join(EG_DIR, 'rogue1.py')
class CharacterFileTestCase(unittest.TestCase):
example_dir = Path(__file__).parent.parent / "examples"
# def test_(self):
# print(self.example_dir)
# subprocess.run(['makesheets', self.example_dir])
def test_load_character_file(self):
charfile = CHARFILE
result = make_sheets.load_character_file(charfile)
self.assertEqual(result['strength'], 10)
class PdfOutputTeestCase(unittest.TestCase):
basename = 'clara'
def tearDown(self):
temp_files = [f'{self.basename}.pdf']
for f in temp_files:
if os.path.exists(f):
os.remove(f)
def test_file_created(self):
# Check that a file is created once the function is run
pdf_name = f'{self.basename}.pdf'
# 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(character=char, basename=self.basename)
self.assertTrue(os.path.exists(pdf_name), f'{pdf_name} not created.')