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_orphan('Orphan-HOWTO', ex)
|
||||
self.add_broken('Broken-HOWTO', ex)
|
||||
argv = ['--pubdir', c.pubdir, '--sourcedir', c.sourcedir[0]]
|
||||
fullpath = opj(self.tempdir, 'sources', 'New-HOWTO.sgml')
|
||||
argv = self.argv
|
||||
argv.extend(['--publish', 'stale', 'Orphan-HOWTO', fullpath])
|
||||
tldp.driver.run(argv)
|
||||
inv = tldp.inventory.Inventory(c.pubdir, c.sourcedir)
|
||||
|
@ -274,8 +274,8 @@ class TestDriverRun(TestInventoryBase):
|
|||
def test_run_extra_args(self):
|
||||
c = self.config
|
||||
self.add_new('New-HOWTO', example.ex_linuxdoc)
|
||||
argv = ['--pubdir', c.pubdir, '--sourcedir', c.sourcedir[0]]
|
||||
fullpath = opj(self.tempdir, 'sources', 'New-HOWTO.sgml')
|
||||
argv = self.argv
|
||||
argv.extend(['--build', 'stale', 'Orphan-HOWTO', fullpath, 'extra'])
|
||||
val = tldp.driver.run(argv)
|
||||
self.assertTrue('Unknown arguments' in val)
|
||||
|
@ -284,29 +284,40 @@ class TestDriverRun(TestInventoryBase):
|
|||
c = self.config
|
||||
ex = example.ex_linuxdoc
|
||||
self.add_new('New-HOWTO', ex)
|
||||
argv = ['--builddir', c.builddir, ]
|
||||
argv.extend(['--pubdir', c.pubdir, ])
|
||||
argv.extend(['--sourcedir', c.sourcedir[0]])
|
||||
tldp.driver.run(argv)
|
||||
tldp.driver.run(self.argv)
|
||||
docbuilddir = opj(c.builddir, ex.doctype.__name__)
|
||||
inv = tldp.inventory.Inventory(docbuilddir, c.sourcedir)
|
||||
self.assertEquals(1, len(inv.published.keys()))
|
||||
|
||||
def test_run_oops_no_sourcedir(self):
|
||||
c = self.config
|
||||
argv = ['--pubdir', c.pubdir]
|
||||
ex = example.ex_linuxdoc
|
||||
self.add_new('New-HOWTO', ex)
|
||||
argv = ['--pubdir', c.pubdir]
|
||||
exit = tldp.driver.run(argv)
|
||||
self.assertTrue('required for inventory' in exit)
|
||||
exitcode = tldp.driver.run(argv)
|
||||
self.assertTrue('required for inventory' in exitcode)
|
||||
|
||||
def test_run_oops_no_pubdir(self):
|
||||
c = self.config
|
||||
argv = ['--sourcedir', c.sourcedir[0]]
|
||||
ex = example.ex_linuxdoc
|
||||
self.add_new('New-HOWTO', ex)
|
||||
argv = ['--sourcedir', c.sourcedir[0]]
|
||||
exit = tldp.driver.run(argv)
|
||||
self.assertTrue('required for inventory' in exit)
|
||||
exitcode = tldp.driver.run(argv)
|
||||
self.assertTrue('required for inventory' in exitcode)
|
||||
|
||||
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):
|
||||
|
|
|
@ -108,11 +108,18 @@ class TestOutputDirSkeleton(OutputNamingConvention):
|
|||
if not os.path.isdir(self.dirname):
|
||||
os.mkdir(self.dirname)
|
||||
|
||||
def create_expected_docs(self):
|
||||
def create_expected_docs(self, func=None):
|
||||
for name in self.expected:
|
||||
fname = getattr(self, name)
|
||||
with open(fname, 'w'):
|
||||
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):
|
||||
|
@ -144,6 +151,12 @@ class TestInventoryBase(unittest.TestCase):
|
|||
c.pubdir = os.path.join(self.tempdir, 'outputs')
|
||||
c.builddir = os.path.join(self.tempdir, 'builddir')
|
||||
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):
|
||||
if not os.path.isdir(d):
|
||||
os.mkdir(d)
|
||||
|
@ -162,8 +175,7 @@ class TestInventoryBase(unittest.TestCase):
|
|||
c = self.config
|
||||
myoutput = TestOutputDirSkeleton(os.path.join(c.pubdir, stem), stem)
|
||||
myoutput.mkdir()
|
||||
myoutput.create_expected_docs()
|
||||
time.sleep(0.001)
|
||||
myoutput.create_stale_expected_docs()
|
||||
mysource = TestSourceDocSkeleton(c.sourcedir)
|
||||
mysource.addsourcefile(stem + ex.ext, ex.filename)
|
||||
|
||||
|
|
Loading…
Reference in New Issue