Warning!

Notice: the grml team is migrating from Mercurial to Git.
Please visit git.grml.org instead!

reposearch_tests: unification of testcases
authorMichael Gebetsroither <michael.geb@gmx.at>
Mon Mar 24 20:59:11 2008 +0100 (8 months ago)
changeset 1837c97f5a46067
manifest7c97f5a46067
parent 182751ab45c49c8
child 184127fe4ea35e9
reposearch_tests: unification of testcases
tests/reposearch_tests.py
--- a/tests/reposearch_tests.py Mon Mar 24 17:31:30 2008 +0100
+++ b/tests/reposearch_tests.py Mon Mar 24 20:59:11 2008 +0100
@@ -9,7 +9,9 @@ import unittest
class Base(unittest.TestCase):
dir = "reposearch_data"
+ data = []
def inner(self, f):
+ '''Execute f() inside self.dir'''
old = op.abspath(os.curdir)
os.chdir(self.dir)
try:
@@ -17,56 +19,46 @@ class Base(unittest.TestCase):
finally:
os.chdir(old)
return tmp
+ def innerT(self, walkfun, testdir, repotype):
+ '''Test walkfun()/2 inside testdir on repotype'''
+ should = self.data
+ curr = sorted(self.inner(lambda: list(walkfun(testdir, rs.repo_types[repotype]))))
+ self.assertEqual(should, curr)
+ def outerT(self, walkfun, testdir, repotype):
+ '''Test walkfun()/2 from outside testdir on repotype'''
+ should = sorted([ op.join(self.dir, i) for i in self.data ])
+ curr = sorted(list(walkfun(op.join(self.dir, testdir), rs.repo_types[repotype])))
+ self.assertEqual(should, curr)
class GitFlat(Base):
- data = 'git/a git/b'.split()
+ data = sorted('git/a git/b'.split())
def testFlatOuter(self):
- '''Test walkrepos_flat from outer directory'''
- should = [ op.join(self.dir, i) for i in self.data ]
- curr = list(rs.walkrepos_flat(
- op.join(self.dir, 'git'), rs.repo_types['git']))
- self.assertEqual(should, curr)
+ self.outerT(rs.walkrepos_flat, 'git', 'git')
def testFlatInner(self):
- should = self.data
- curr = self.inner(lambda: list(rs.walkrepos_flat('git', rs.repo_types['git'])))
- self.assertEqual(should, curr)
+ self.innerT(rs.walkrepos_flat, 'git', 'git')
class GitRec(Base):
- data = 'git/a git/b git/dir/a git/dir/b'.split()
+ data = sorted('git/a git/b git/dir/a git/dir/b'.split())
def testRecOuter(self):
- should = [ op.join(self.dir, i) for i in self.data ]
- curr = list(rs.walkrepos(
- op.join(self.dir, 'git'), rs.repo_types['git']))
- self.assertEqual(should, curr)
+ self.outerT(rs.walkrepos, 'git', 'git')
def testRecInner(self):
- should = self.data
- curr = self.inner(lambda: list(rs.walkrepos('git', rs.repo_types['git'])))
- self.assertEqual(should, curr)
+ self.innerT(rs.walkrepos, 'git', 'git')
class GitBareFlat(Base):
- data = 'gitbare/a.git gitbare/b.git'.split()
+ data = sorted('gitbare/a.git gitbare/b.git'.split())
def testFlatOuter(self):
- should = [ op.join(self.dir, i) for i in self.data ]
- curr = list(rs.walkrepos_flat(
- op.join(self.dir, 'gitbare'), rs.repo_types['gitbare']))
- self.assertEqual(should, curr)
+ self.outerT(rs.walkrepos_flat, 'gitbare', 'gitbare')
def testFlatInner(self):
- should = self.data
- curr = self.inner(lambda: list(rs.walkrepos_flat('gitbare', rs.repo_types['gitbare'])))
- self.assertEqual(should, curr)
+ self.innerT(rs.walkrepos_flat, 'gitbare', 'gitbare')
class GitBareRec(Base):
- data = 'gitbare/a.git gitbare/b.git gitbare/dir/a.git gitbare/dir/b.git'.split()
+ data = sorted('gitbare/a.git gitbare/b.git gitbare/dir/a.git gitbare/dir/b.git'.split())
def testRecOuter(self):
- should = [ op.join(self.dir, i) for i in self.data ]
- curr = list(rs.walkrepos(
- op.join(self.dir, 'gitbare'), rs.repo_types['gitbare']))
- self.assertEqual(should, curr)
+ self.outerT(rs.walkrepos, 'gitbare', 'gitbare')
def testRecInner(self):
- should = self.data
- curr = self.inner(lambda: list(rs.walkrepos('gitbare', rs.repo_types['gitbare'])))
- self.assertEqual(should, curr)
+ self.innerT(rs.walkrepos, 'gitbare', 'gitbare')
if __name__ == "__main__":
unittest.main()
+