def testing_schema_namespace(): conf = { 'my.thing.one': '1', 'my.thing.two': 'another', 'my.thing.three.four': 'deeper' } with testing.MockConfiguration(conf, namespace=ATestingSchema.namespace): yield
def test_mock_configuration_context_manager(self): one = self.getters.get('one') three = self.getters.get_int('three', default=3) with testing.MockConfiguration(dict(one=7), namespace=self.namespace): assert_equal(one, 7) assert_equal(three, 3) assert_raises(errors.ConfigurationError, self.getters.get('one'))
def setup_config(self): conf = { 'my.thing.one': '1', 'my.thing.two': 'another', 'my.thing.three.four': 'deeper' } with testing.MockConfiguration(conf, namespace=TestingSchema.namespace): yield
def test_nested(self): with testing.MockConfiguration(a='one', b='two'): with testing.PatchConfiguration(a='three'): assert_equal(staticconf.get('a'), 'three') assert_equal(staticconf.get('b'), 'two') assert_equal(staticconf.get('a'), 'one') assert_equal(staticconf.get('b'), 'two')
def test_init_nested(self): conf = { 'a': { 'b': 'two', }, 'c': 'three' } with testing.MockConfiguration(conf): assert_equal(staticconf.get('a.b'), 'two') assert_equal(staticconf.get('c'), 'three')
def test_mock_configuration(self): two = staticconf.get_string('two') stars = staticconf.get_bool('stars') mock_config = testing.MockConfiguration(dict(two=2, stars=False)) mock_config.setup() assert_equal(two, '2') assert not stars mock_config.teardown() assert_raises(errors.ConfigurationError, staticconf.get('two'))
def patch_namespace(self): self.namespace = 'testing_namespace' with testing.MockConfiguration(namespace=self.namespace): yield
def teardown_proxies(self): self.namespace = 'the_test_namespace' with testing.MockConfiguration(namespace=self.namespace): yield
def teardown_proxies(self): with testing.MockConfiguration(): yield
def test_init(self): with testing.MockConfiguration(a='one', b='two'): assert_equal(staticconf.get('a'), 'one') assert_equal(staticconf.get('b'), 'two')
def patch_config(self): self.namespace = 'the_name' with testing.MockConfiguration(self.config, namespace=self.namespace): yield
def patch_config(self): with mock.patch.dict(config.configuration_namespaces, clear=True): with testing.MockConfiguration(): yield