From 7be65237acd7fe91a6693d9c2518a8a0c849d672 Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Mon, 5 Sep 2016 17:34:34 +0200 Subject: testsuite: Only sync the database once per TestCase --- testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'testsuite/Testsrc/Testlib/TestServer/TestPlugin') 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 """ -- cgit v1.2.3-1-g7c22