Test file reader

This commit is contained in:
Jake Howard 2017-06-08 12:26:15 +01:00
parent 392703e3cb
commit ddb51ceee4
2 changed files with 17 additions and 1 deletions

View file

@ -6,7 +6,7 @@ from md_pdf.exceptions import ConfigValidationException
def load_config(location=CONFIG_FILE):
try:
with open(os.path.join(location)) as f:
with open(location) as f:
return yaml.safe_load(f)
except FileNotFoundError:
raise ConfigValidationException("Can't find config file at {}".format(CONFIG_FILE))

View file

@ -1,7 +1,23 @@
from tests import BaseTestCase
from md_pdf.build.pandoc import output_html, build_document
from md_pdf.build.md import read_files
from md_pdf.utils import remove_dir
import os
import glob
class ReadFileTestCase(BaseTestCase):
file_glob = 'test-files/*.md'
def test_reads_files(self):
files = read_files(self.file_glob)
self.assertNotEqual(files, '')
def test_contains_all_files(self):
files = read_files(self.file_glob)
for file in glob.iglob(self.file_glob):
with open(file) as f:
self.assertIn(f.read(), files)
class OutputHTMLTestCase(BaseTestCase):