def test_validateDirs_multibad(self): invalid0 = os.path.join(self.tempdir, 'unique', 'rabbit') invalid1 = os.path.join(self.tempdir, 'affable', 'elephant') with self.assertRaises(IOError) as ecm: scansourcedirs([invalid0, invalid1]) e = ecm.exception self.assertTrue('affable/elephant' in e.filename)
def test_skipping_misnamed_singlefile(self): ex = random.choice(example.sources) maindir = 'LDP/LDP/howto' reldir, absdir = self.adddir(maindir) self.addfile(reldir, ex.filename, ext=".mis") s = scansourcedirs([absdir]) self.assertEqual(1, len(s))
def test_finding_singlefile(self): ex = random.choice(example.sources) maindir = 'LDP/LDP/howto' reldir, absdir = self.adddir(maindir) _, _ = self.addfile(reldir, ex.filename) s = scansourcedirs([absdir]) self.assertEqual(1, len(s))
def test_multiple_stems_of_different_extensions(self): ex = random.choice(example.sources) stem = 'A-Non-Unique-Stem' maindir = os.path.join('LDP/LDP/howto', stem) reldir, absdir = self.adddir(maindir) self.addfile(reldir, ex.filename, stem=stem, ext=".xml") self.addfile(reldir, ex.filename, stem=stem, ext=".md") s = scansourcedirs([absdir]) self.assertEqual(1, len(s))
def test_multidir_finding_namecollision(self): ex = random.choice(example.sources) doc0 = Namespace(reldir='LDP/howto', stem="A-Non-Unique-Stem") doc1 = Namespace(reldir='LDP/guide', stem="A-Non-Unique-Stem") documents = (doc0, doc1) for d in documents: d.reldir, d.absdir = self.adddir(d.reldir) _, _ = self.addfile(d.reldir, ex.filename, stem=d.stem) s = scansourcedirs([x.absdir for x in documents]) self.assertEqual(1, len(s)) expected = set([x.stem for x in documents]) found = set(s.keys()) self.assertEqual(expected, found)
def test_finding_nonfile(self): maindir = 'LDP/LDP/howto' reldir, absdir = self.adddir(maindir) os.mkfifo(os.path.join(absdir, 'non-dir-non-file.xml')) s = scansourcedirs([absdir]) self.assertEqual(0, len(s))
def testEmptyDir(self): s = scansourcedirs([self.tempdir]) self.assertEqual(0, len(s))
def test_validateDirs_onebad(self): invalid0 = os.path.join(self.tempdir, 'unique', 'rabbit') with self.assertRaises(IOError) as ecm: scansourcedirs([invalid0]) e = ecm.exception self.assertTrue('unique/rabbit' in e.filename)