mirror of https://github.com/tLDP/python-tldp
minor simplifications to testing tools
This commit is contained in:
parent
46d16f4ccb
commit
7e3fa95813
|
@ -263,8 +263,8 @@ class TestDriverRun(TestInventoryBase):
|
||||||
self.add_stale('Stale-HOWTO', ex)
|
self.add_stale('Stale-HOWTO', ex)
|
||||||
self.add_orphan('Orphan-HOWTO', ex)
|
self.add_orphan('Orphan-HOWTO', ex)
|
||||||
self.add_broken('Broken-HOWTO', ex)
|
self.add_broken('Broken-HOWTO', ex)
|
||||||
argv = ['--pubdir', c.pubdir, '--sourcedir', c.sourcedir[0]]
|
|
||||||
fullpath = opj(self.tempdir, 'sources', 'New-HOWTO.sgml')
|
fullpath = opj(self.tempdir, 'sources', 'New-HOWTO.sgml')
|
||||||
|
argv = self.argv
|
||||||
argv.extend(['--publish', 'stale', 'Orphan-HOWTO', fullpath])
|
argv.extend(['--publish', 'stale', 'Orphan-HOWTO', fullpath])
|
||||||
tldp.driver.run(argv)
|
tldp.driver.run(argv)
|
||||||
inv = tldp.inventory.Inventory(c.pubdir, c.sourcedir)
|
inv = tldp.inventory.Inventory(c.pubdir, c.sourcedir)
|
||||||
|
@ -274,8 +274,8 @@ class TestDriverRun(TestInventoryBase):
|
||||||
def test_run_extra_args(self):
|
def test_run_extra_args(self):
|
||||||
c = self.config
|
c = self.config
|
||||||
self.add_new('New-HOWTO', example.ex_linuxdoc)
|
self.add_new('New-HOWTO', example.ex_linuxdoc)
|
||||||
argv = ['--pubdir', c.pubdir, '--sourcedir', c.sourcedir[0]]
|
|
||||||
fullpath = opj(self.tempdir, 'sources', 'New-HOWTO.sgml')
|
fullpath = opj(self.tempdir, 'sources', 'New-HOWTO.sgml')
|
||||||
|
argv = self.argv
|
||||||
argv.extend(['--build', 'stale', 'Orphan-HOWTO', fullpath, 'extra'])
|
argv.extend(['--build', 'stale', 'Orphan-HOWTO', fullpath, 'extra'])
|
||||||
val = tldp.driver.run(argv)
|
val = tldp.driver.run(argv)
|
||||||
self.assertTrue('Unknown arguments' in val)
|
self.assertTrue('Unknown arguments' in val)
|
||||||
|
@ -284,29 +284,40 @@ class TestDriverRun(TestInventoryBase):
|
||||||
c = self.config
|
c = self.config
|
||||||
ex = example.ex_linuxdoc
|
ex = example.ex_linuxdoc
|
||||||
self.add_new('New-HOWTO', ex)
|
self.add_new('New-HOWTO', ex)
|
||||||
argv = ['--builddir', c.builddir, ]
|
tldp.driver.run(self.argv)
|
||||||
argv.extend(['--pubdir', c.pubdir, ])
|
|
||||||
argv.extend(['--sourcedir', c.sourcedir[0]])
|
|
||||||
tldp.driver.run(argv)
|
|
||||||
docbuilddir = opj(c.builddir, ex.doctype.__name__)
|
docbuilddir = opj(c.builddir, ex.doctype.__name__)
|
||||||
inv = tldp.inventory.Inventory(docbuilddir, c.sourcedir)
|
inv = tldp.inventory.Inventory(docbuilddir, c.sourcedir)
|
||||||
self.assertEquals(1, len(inv.published.keys()))
|
self.assertEquals(1, len(inv.published.keys()))
|
||||||
|
|
||||||
def test_run_oops_no_sourcedir(self):
|
def test_run_oops_no_sourcedir(self):
|
||||||
c = self.config
|
c = self.config
|
||||||
|
argv = ['--pubdir', c.pubdir]
|
||||||
ex = example.ex_linuxdoc
|
ex = example.ex_linuxdoc
|
||||||
self.add_new('New-HOWTO', ex)
|
self.add_new('New-HOWTO', ex)
|
||||||
argv = ['--pubdir', c.pubdir]
|
exitcode = tldp.driver.run(argv)
|
||||||
exit = tldp.driver.run(argv)
|
self.assertTrue('required for inventory' in exitcode)
|
||||||
self.assertTrue('required for inventory' in exit)
|
|
||||||
|
|
||||||
def test_run_oops_no_pubdir(self):
|
def test_run_oops_no_pubdir(self):
|
||||||
c = self.config
|
c = self.config
|
||||||
|
argv = ['--sourcedir', c.sourcedir[0]]
|
||||||
ex = example.ex_linuxdoc
|
ex = example.ex_linuxdoc
|
||||||
self.add_new('New-HOWTO', ex)
|
self.add_new('New-HOWTO', ex)
|
||||||
argv = ['--sourcedir', c.sourcedir[0]]
|
exitcode = tldp.driver.run(argv)
|
||||||
exit = tldp.driver.run(argv)
|
self.assertTrue('required for inventory' in exitcode)
|
||||||
self.assertTrue('required for inventory' in exit)
|
|
||||||
|
def test_run_status_selection(self):
|
||||||
|
self.add_docbook4xml_xsl_to_config()
|
||||||
|
c = self.config
|
||||||
|
c.script = True
|
||||||
|
stdout = StringIO()
|
||||||
|
self.add_stale('Asciidoc-Stale-HOWTO', example.ex_asciidoc)
|
||||||
|
self.add_new('DocBook4XML-New-HOWTO', example.ex_docbook4xml)
|
||||||
|
argv = self.argv
|
||||||
|
argv.extend(['--publish', 'stale'])
|
||||||
|
exitcode = tldp.driver.run(argv)
|
||||||
|
self.assertEquals(exitcode, os.EX_OK)
|
||||||
|
inv = tldp.inventory.Inventory(c.pubdir, c.sourcedir)
|
||||||
|
self.assertEquals(1, len(inv.published.keys()))
|
||||||
|
|
||||||
|
|
||||||
class TestDriverProcessSkips(TestInventoryBase):
|
class TestDriverProcessSkips(TestInventoryBase):
|
||||||
|
|
|
@ -108,11 +108,18 @@ class TestOutputDirSkeleton(OutputNamingConvention):
|
||||||
if not os.path.isdir(self.dirname):
|
if not os.path.isdir(self.dirname):
|
||||||
os.mkdir(self.dirname)
|
os.mkdir(self.dirname)
|
||||||
|
|
||||||
def create_expected_docs(self):
|
def create_expected_docs(self, func=None):
|
||||||
for name in self.expected:
|
for name in self.expected:
|
||||||
fname = getattr(self, name)
|
fname = getattr(self, name)
|
||||||
with open(fname, 'w'):
|
with open(fname, 'w'):
|
||||||
pass
|
pass
|
||||||
|
if func:
|
||||||
|
func(fname)
|
||||||
|
|
||||||
|
def create_stale_expected_docs(self):
|
||||||
|
def thirtysecondsago(fname):
|
||||||
|
os.utime(fname, (time.time() - 30, time.time() - 30))
|
||||||
|
self.create_expected_docs(func=thirtysecondsago)
|
||||||
|
|
||||||
|
|
||||||
class TestSourceDocSkeleton(object):
|
class TestSourceDocSkeleton(object):
|
||||||
|
@ -144,6 +151,12 @@ class TestInventoryBase(unittest.TestCase):
|
||||||
c.pubdir = os.path.join(self.tempdir, 'outputs')
|
c.pubdir = os.path.join(self.tempdir, 'outputs')
|
||||||
c.builddir = os.path.join(self.tempdir, 'builddir')
|
c.builddir = os.path.join(self.tempdir, 'builddir')
|
||||||
c.sourcedir = os.path.join(self.tempdir, 'sources')
|
c.sourcedir = os.path.join(self.tempdir, 'sources')
|
||||||
|
argv = list()
|
||||||
|
argv.extend(['--builddir', c.builddir])
|
||||||
|
argv.extend(['--pubdir', c.pubdir])
|
||||||
|
argv.extend(['--sourcedir', c.sourcedir])
|
||||||
|
self.argv = argv
|
||||||
|
# -- and make some directories
|
||||||
for d in (c.sourcedir, c.pubdir, c.builddir):
|
for d in (c.sourcedir, c.pubdir, c.builddir):
|
||||||
if not os.path.isdir(d):
|
if not os.path.isdir(d):
|
||||||
os.mkdir(d)
|
os.mkdir(d)
|
||||||
|
@ -162,8 +175,7 @@ class TestInventoryBase(unittest.TestCase):
|
||||||
c = self.config
|
c = self.config
|
||||||
myoutput = TestOutputDirSkeleton(os.path.join(c.pubdir, stem), stem)
|
myoutput = TestOutputDirSkeleton(os.path.join(c.pubdir, stem), stem)
|
||||||
myoutput.mkdir()
|
myoutput.mkdir()
|
||||||
myoutput.create_expected_docs()
|
myoutput.create_stale_expected_docs()
|
||||||
time.sleep(0.001)
|
|
||||||
mysource = TestSourceDocSkeleton(c.sourcedir)
|
mysource = TestSourceDocSkeleton(c.sourcedir)
|
||||||
mysource.addsourcefile(stem + ex.ext, ex.filename)
|
mysource.addsourcefile(stem + ex.ext, ex.filename)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue