From 5e77b77765154850fb708e6ea188fcf7ba99fdce Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 30 Aug 2012 04:37:30 +0900 Subject: add test for JSONLeapConfig metaclass --- src/leap/base/tests/test_config.py | 39 +++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) (limited to 'src/leap/base/tests') diff --git a/src/leap/base/tests/test_config.py b/src/leap/base/tests/test_config.py index ef897a23..40461b99 100644 --- a/src/leap/base/tests/test_config.py +++ b/src/leap/base/tests/test_config.py @@ -23,6 +23,38 @@ except ImportError: _system = platform.system() +class JSONLeapConfigTest(BaseLeapTest): + def setUp(self): + pass + + def tearDown(self): + pass + + def test_metaclass(self): + with self.assertRaises(exceptions.ImproperlyConfigured) as exc: + class DummyTestConfig(config.JSONLeapConfig): + __metaclass__ = config.MetaConfigWithSpec + exc.startswith("missing spec dict") + + class DummyTestConfig(config.JSONLeapConfig): + __metaclass__ = config.MetaConfigWithSpec + spec = {} + with self.assertRaises(exceptions.ImproperlyConfigured) as exc: + DummyTestConfig() + exc.startswith("missing slug") + + class DummyTestConfig(config.JSONLeapConfig): + __metaclass__ = config.MetaConfigWithSpec + spec = {} + slug = "foo" + DummyTestConfig() + +######################################3 +# +# provider fetch tests block +# + + class ProviderTest(BaseLeapTest): # override per test fixtures @@ -45,7 +77,7 @@ class BareHomeTestCase(ProviderTest): class ProviderDefinitionTestCase(ProviderTest): - # XXX See how to merge with test_providers + # XXX MOVE TO eip.test_checks # -- kali 2012-08-24 00:38 __name__ = "provider_config_tests" @@ -62,10 +94,6 @@ class ProviderDefinitionTestCase(ProviderTest): json.dump(eipconstants.EIP_SAMPLE_JSON, fp) -# -# provider fetch tests block -# - # these tests below should move to wherever # we put the fetcher for provider files and related stuff. # TODO: @@ -107,6 +135,7 @@ class ProviderFetchInvalidUrl(ProviderTest): # end provider fetch tests +########################################### class ConfigHelperFunctions(BaseLeapTest): -- cgit v1.2.3