From 3580544b7ca6c5ef377ecba52fb20e32249b984f Mon Sep 17 00:00:00 2001 From: "Martin A. Brown" Date: Fri, 26 Feb 2016 12:49:09 -0800 Subject: [PATCH] and test a directory-shaped document --- tests/example.py | 6 ++++++ tests/test_sources.py | 20 ++++++++++++++------ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/example.py b/tests/example.py index 31a6072..1a8e6a4 100644 --- a/tests/example.py +++ b/tests/example.py @@ -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_')] diff --git a/tests/test_sources.py b/tests/test_sources.py index 6e35878..b2a50bf 100644 --- a/tests/test_sources.py +++ b/tests/test_sources.py @@ -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):