summaryrefslogtreecommitdiffstats
path: root/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander.sulfrian@fu-berlin.de>2016-09-05 17:34:34 +0200
committerAlexander Sulfrian <alexander.sulfrian@fu-berlin.de>2016-09-05 17:34:34 +0200
commit7be65237acd7fe91a6693d9c2518a8a0c849d672 (patch)
tree781a7134fac0b482f2311a3df7427b610827953d /testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py
parent7586aee42bc37432ad07638e254997540aa34007 (diff)
downloadbcfg2-7be65237acd7fe91a6693d9c2518a8a0c849d672.tar.gz
bcfg2-7be65237acd7fe91a6693d9c2518a8a0c849d672.tar.bz2
bcfg2-7be65237acd7fe91a6693d9c2518a8a0c849d672.zip
testsuite: Only sync the database once per TestCase
Diffstat (limited to 'testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py')
-rw-r--r--testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py
index 5a82100d0..9f6a9f320 100644
--- a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py
+++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py
@@ -51,6 +51,7 @@ class TestFunctions(Bcfg2TestCase):
class TestDatabaseBacked(TestPlugin):
test_obj = DatabaseBacked
+ synced = False
def setUp(self):
TestPlugin.setUp(self)
@@ -76,6 +77,15 @@ class TestDatabaseBacked(TestPlugin):
setattr(Bcfg2.Options.setup, attr, True)
self.assertRaises(PluginInitError, self.get_obj, core)
+ def syncdb(self, modeltest):
+ """ Given an instance of a :class:`DBModelTestCase` object, sync
+ and clean the database """
+ inst = modeltest(methodName='test_syncdb')
+ if not self.__class__.synced:
+ inst.test_syncdb()
+ self.__class__.synced = True
+ inst.test_cleandb()
+
class TestPluginDatabaseModel(Bcfg2TestCase):
""" placeholder for future tests """