def test_build_getter(self): validator = mock.Mock() getter = getters.build_getter(validator) assert callable(getter), "Getter is not callable" value_proxy = getter('the_name') namespace = config.get_namespace(config.DEFAULT) assert_in(id(value_proxy), namespace.value_proxies) assert_equal(value_proxy.config_key, "the_name") assert_equal(value_proxy.namespace, namespace)
def test_build_getter(self): validator = mock.Mock() getter = getters.build_getter(validator) assert callable(getter), "Getter is not callable" value_proxy = getter('the_name') namespace = config.get_namespace(config.DEFAULT) assert value_proxy is namespace.get_value_proxies()[-1] assert_equal(value_proxy.config_key, "the_name") assert_equal(value_proxy.value_cache, namespace.configuration_values)
def test_build_getter_with_getter_namespace(self): validator = mock.Mock() name = 'the stars' getter = getters.build_getter(validator, getter_namespace=name) assert callable(getter), "Getter is not callable" value_proxy = getter('the_name') namespace = config.get_namespace(name) assert_in(id(value_proxy), namespace.value_proxies) assert_equal(value_proxy.config_key, "the_name") assert_equal(value_proxy.namespace, namespace)
path = 'config/rssdigest.yaml' app_name = 'rss-digest' app_namespace = 'app_config' def load(path=path): staticconf.YamlConfiguration(path) def validate_utc_datetime(value): tz = pytz.timezone('UTC') return validation.validate_datetime(value).replace(tzinfo=tz) get_utc_datetime = getters.build_getter(validate_utc_datetime) # TODO:make staticconf.Schema accept a path argument class FeedConfig(object): def __init__(self, config_dict): self.config = config_dict def __getattr__(self, name): return self.config[name] def validate_feed_config(value): return FeedConfig(value)