summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJan Pokorný <jpokorny@redhat.com>2015-12-02 21:07:38 +0100
committerJan Pokorný <jpokorny@redhat.com>2015-12-17 23:36:01 +0100
commit9cc8be37d42468afef8c1867e8928f0fd4e6b6e8 (patch)
treebd68c03104b2b7beb6a2604979a1721cd9dac082 /tests
parent68c0521a680dac89d046a631064f315a2c9e29b0 (diff)
downloadclufter-9cc8be37d42468afef8c1867e8928f0fd4e6b6e8.tar.gz
clufter-9cc8be37d42468afef8c1867e8928f0fd4e6b6e8.tar.xz
clufter-9cc8be37d42468afef8c1867e8928f0fd4e6b6e8.zip
tests: move rewrite_root to the common base for testing
Signed-off-by: Jan Pokorný <jpokorny@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/_com15
-rw-r--r--tests/filters/ccsflat2cibprelude.py17
2 files changed, 16 insertions, 16 deletions
diff --git a/tests/_com b/tests/_com
index 7e8f993..61ce2f8 100644
--- a/tests/_com
+++ b/tests/_com
@@ -9,11 +9,26 @@ __author__ = "Jan Pokorný <jpokorny @at@ Red Hat .dot. com>"
from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_go'))
+from os.path import dirname, join, split
+from sys import modules
from unittest import TestCase
from .filter_manager import FilterManager
+def rewrite_root(flt, new_root):
+ # /foo/bar -> (/foo, bar)
+ # /foo/bar/ -> (/foo/bar, )
+ new_root_dir, new_xml_root = split(new_root)
+ old_root_dir = dirname(modules[flt.__class__.__module__].__file__)
+ new_root_dir = join(old_root_dir, new_root_dir)
+ flt._fnc = (lambda orig_fnc:
+ lambda *args, **kwargs: orig_fnc(*args, root_dir=new_root_dir,
+ xml_root=new_xml_root, **kwargs)
+ )(flt._fnc)
+ return flt
+
+
class CommonFilterTestCase(TestCase):
def setUp(self):
self.flt_mgr = FilterManager.init_lookup(ext_plugins=False)
diff --git a/tests/filters/ccsflat2cibprelude.py b/tests/filters/ccsflat2cibprelude.py
index b6ce412..7953b1e 100644
--- a/tests/filters/ccsflat2cibprelude.py
+++ b/tests/filters/ccsflat2cibprelude.py
@@ -5,26 +5,11 @@
"""Testing `ccsflat2cibprelude' filter"""
__author__ = "Jan Pokorný <jpokorny @at@ Red Hat .dot. com>"
+# following makes available also: TeardownFilterTestCase, rewrite_root
from os.path import join, dirname as d; execfile(join(d(d((__file__))), '_com'))
-from os.path import dirname, join, split
-from sys import modules
-
flt = 'ccsflat2cibprelude'
-def rewrite_root(flt, new_root):
- # /foo/bar -> (/foo, bar)
- # /foo/bar/ -> (/foo/bar, )
- new_root_dir, new_xml_root = split(new_root)
- old_root_dir = dirname(modules[flt.__class__.__module__].__file__)
- new_root_dir = join(old_root_dir, new_root_dir)
- flt._fnc = (lambda orig_fnc:
- lambda *args, **kwargs: orig_fnc(*args, root_dir=new_root_dir,
- xml_root=new_xml_root, **kwargs)
- )(flt._fnc)
- return flt
-
-
class FiltersCcsFlat2CibPreludeTestCase(TeardownFilterTestCase):
def testNfsClient(self):
flt_obj = rewrite_root(self.flt_mgr.filters[flt], 'cluster/rm')