mirror of https://github.com/tLDP/python-tldp
improving coverage of cases in OutputDirectory and OutputCollection
This commit is contained in:
parent
fbb6e56929
commit
ce060fc5d0
|
@ -17,7 +17,7 @@ except ImportError:
|
||||||
from tldptesttools import *
|
from tldptesttools import *
|
||||||
|
|
||||||
# -- Test Data
|
# -- Test Data
|
||||||
import examples
|
import example
|
||||||
|
|
||||||
# -- SUT
|
# -- SUT
|
||||||
from tldp.outputs import OutputCollection
|
from tldp.outputs import OutputCollection
|
||||||
|
@ -27,12 +27,6 @@ from tldp.outputs import OutputNamingConvention
|
||||||
datadir = os.path.join(os.path.dirname(__file__), 'testdata')
|
datadir = os.path.join(os.path.dirname(__file__), 'testdata')
|
||||||
|
|
||||||
|
|
||||||
def stem_and_ext(name):
|
|
||||||
stem, ext = os.path.splitext(os.path.basename(name))
|
|
||||||
assert ext != ''
|
|
||||||
return stem, ext
|
|
||||||
|
|
||||||
|
|
||||||
class TestOutputNamingConvention(unittest.TestCase):
|
class TestOutputNamingConvention(unittest.TestCase):
|
||||||
|
|
||||||
def test_namesets(self):
|
def test_namesets(self):
|
||||||
|
@ -44,7 +38,7 @@ class TestOutputNamingConvention(unittest.TestCase):
|
||||||
self.assertTrue(onc.name_index.endswith("index.html"))
|
self.assertTrue(onc.name_index.endswith("index.html"))
|
||||||
|
|
||||||
|
|
||||||
class TestMissingOutputCollection(TestToolsFilesystem):
|
class TestOutputCollection(TestToolsFilesystem):
|
||||||
|
|
||||||
def test_not_a_directory(self):
|
def test_not_a_directory(self):
|
||||||
missing = os.path.join(self.tempdir, 'vanishing')
|
missing = os.path.join(self.tempdir, 'vanishing')
|
||||||
|
@ -53,5 +47,31 @@ class TestMissingOutputCollection(TestToolsFilesystem):
|
||||||
e = ecm.exception
|
e = ecm.exception
|
||||||
self.assertEquals(errno.ENOENT, e.errno)
|
self.assertEquals(errno.ENOENT, e.errno)
|
||||||
|
|
||||||
|
def test_file_in_output_collection(self):
|
||||||
|
reldir, absdir = self.adddir('collection')
|
||||||
|
self.addfile('collection', __file__, stem='non-directory')
|
||||||
|
oc = OutputCollection(absdir)
|
||||||
|
self.assertEquals(0, len(oc))
|
||||||
|
|
||||||
|
def test_manyfiles(self):
|
||||||
|
reldir, absdir = self.adddir('manyfiles')
|
||||||
|
count = random.randint(8, 15)
|
||||||
|
for x in range(count):
|
||||||
|
self.adddir('manyfiles/Document-Stem-' + str(x))
|
||||||
|
oc = OutputCollection(absdir)
|
||||||
|
self.assertEquals(count, len(oc))
|
||||||
|
|
||||||
|
|
||||||
|
class TestOutputDirectory(TestToolsFilesystem):
|
||||||
|
|
||||||
|
def test_no_parent_dir(self):
|
||||||
|
odoc = os.path.join(self.tempdir, 'non-existent-parent', 'stem')
|
||||||
|
with self.assertRaises(IOError) as ecm:
|
||||||
|
OutputDirectory(odoc)
|
||||||
|
e = ecm.exception
|
||||||
|
self.assertEquals(errno.ENOENT, e.errno)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# -- end of file
|
# -- end of file
|
||||||
|
|
Loading…
Reference in New Issue