From adf037aa31031be164e68b1a4817a7cada936c90 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Tue, 2 Oct 2012 15:00:03 -0400 Subject: testsuite: added unit tests for Cfg handlers --- .../TestCfg/TestCfgEncryptedGenshiGenerator.py | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestCfg/TestCfgEncryptedGenshiGenerator.py (limited to 'testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestCfg/TestCfgEncryptedGenshiGenerator.py') diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestCfg/TestCfgEncryptedGenshiGenerator.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestCfg/TestCfgEncryptedGenshiGenerator.py new file mode 100644 index 000000000..0375b8928 --- /dev/null +++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestCfg/TestCfgEncryptedGenshiGenerator.py @@ -0,0 +1,35 @@ +import os +import sys +from mock import Mock, MagicMock, patch +from Bcfg2.Server.Plugins.Cfg.CfgEncryptedGenshiGenerator import * + +# add all parent testsuite directories to sys.path to allow (most) +# relative imports in python 2.4 +path = os.path.dirname(__file__) +while path != "/": + if os.path.basename(path).lower().startswith("test"): + sys.path.append(path) + if os.path.basename(path) == "testsuite": + break + path = os.path.dirname(path) +from common import XI_NAMESPACE, XI, inPy3k, call, builtins, u, can_skip, \ + skip, skipIf, skipUnless, Bcfg2TestCase, DBModelTestCase, syncdb, \ + patchIf, datastore, re_type + +try: + from TestServer.TestPlugins.TestCfg.TestCfgGenshiGenerator import \ + TestCfgGenshiGenerator + HAS_GENSHI = True +except ImportError: + TestCfgGenshiGenerator = object + HAS_GENSHI = False + + +if can_skip or (HAS_CRYPTO and HAS_GENSHI): + class TestCfgEncryptedGenshiGenerator(TestCfgGenshiGenerator): + test_obj = CfgEncryptedGenshiGenerator + + @skipUnless(HAS_CRYPTO, "Encryption libraries not found, skipping") + @skipUnless(HAS_GENSHI, "Genshi libraries not found, skipping") + def setUp(self): + pass -- cgit v1.2.3-1-g7c22