def test_proxy_list(self): the_list = range(3) validator = mock.Mock(return_value=the_list) value_proxy = proxy.ValueProxy(validator, self.value_cache, 'the_list') assert_equal(value_proxy, the_list) assert_in(2, value_proxy) assert_equal(value_proxy[:1], range(0, 1)) assert_equal(len(value_proxy), 3)
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_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)
def test_getters(self): get_conf = getters.NamespaceGetters(self.namespace) proxies = [ get_conf.get_bool('is_it'), get_conf.get_time('when'), get_conf.get_list_of_bool('options') ] namespace = config.get_namespace(get_conf.namespace) for proxy in proxies: assert_in(id(proxy), namespace.value_proxies)
def test_build_with_immutable_default(self): args = self.validator, self.namespace, self.config_key, [], self.help self.factory.build(*args) assert_in(repr(args[:-1]), self.factory.proxies)