and test a directory-shaped document

This commit is contained in:
Martin A. Brown 2016-02-26 12:49:09 -08:00
parent ffa2fb6a93
commit 3580544b7c
2 changed files with 20 additions and 6 deletions

View File

@ -57,6 +57,12 @@ ex_markdown = SimpleNamespace(
filename=opj(sampledocs, 'markdown-simple.md'),
)
ex_linuxdoc_dir = SimpleNamespace(
ext='.sgml',
type=tldp.doctypes.linuxdoc.Linuxdoc,
filename=opj(sampledocs, 'Linuxdoc-Larger', 'Linuxdoc-Larger.sgml'),
)
# -- a bit ugly, but grab each dict
sources = [y for x, y in locals().items() if x.startswith('ex_')]

View File

@ -19,7 +19,7 @@ import example
# -- SUT
from tldp.sources import SourceCollection, SourceDocument, scansourcedirs
datadir = os.path.join(os.path.dirname(__file__), 'sample-documents')
sampledocs = os.path.join(os.path.dirname(__file__), 'sample-documents')
class TestFileSourceCollectionMultiDir(TestToolsFilesystem):
@ -118,12 +118,20 @@ class TestInvalidSourceCollection(TestToolsFilesystem):
self.assertEquals(0, len(s))
class TestSourceDocuments(unittest.TestCase):
class TestSourceDocument(unittest.TestCase):
def test_init_missing(self):
doc = SourceDocument(os.path.join(datadir, 'linuxdoc-simple.sgml'))
self.assertIsInstance(doc, SourceDocument)
self.assertTrue("linuxdoc-simple.sgml" in str(doc))
def test_init(self):
for ex in example.sources:
fullpath = ex.filename
fn = os.path.basename(fullpath)
doc = SourceDocument(fullpath)
self.assertIsInstance(doc, SourceDocument)
self.assertTrue(fn in str(doc))
self.assertTrue(fn in doc.statinfo)
def test_detail(self):
fullpath = example.ex_linuxdoc_dir.filename
pass
class TestMissingSourceDocuments(TestToolsFilesystem):