From 51d420b29d0fd7e28315bec64bf80a8aaa4ad2b8 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Wed, 11 Apr 2018 08:40:59 +0200 Subject: [PATCH] add test for properties --- test/test_requires.py | 15 ++++++++++++++- tiramisu/api.py | 4 ++-- tiramisu/error.py | 3 ++- tiramisu/setting.py | 10 ++++++---- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/test/test_requires.py b/test/test_requires.py index 04f2b10..fc69aae 100644 --- a/test/test_requires.py +++ b/test/test_requires.py @@ -392,7 +392,20 @@ def test_requires_transitive_hidden_disabled_multiple(): except PropertiesOptionError as err: props = err.proptype assert set(props) == {'disabled', 'hidden'} - raises(RequirementError, "api.option('ip_address_service_web').value.get()") + req = None + try: + api.option('ip_address_service_web').value.get() + except RequirementError as err: + req = err + assert req, "ip_address_service_web should raise RequirementError" + assert str(req) == str(_('cannot access to option "{}" because required option "{}" has {} {}').format('ip_address_service_web', 'activate_service_web', 'property', '"disabled"')) + api.permissive.set(frozenset()) + try: + api.option('ip_address_service_web').value.get() + except RequirementError as err: + req = err + assert req, "ip_address_service_web should raise RequirementError" + assert str(req) == str(_('cannot access to option "{}" because required option "{}" has {} {}').format('ip_address_service_web', 'activate_service_web', 'properties', '"disabled" and "hidden"')) def test_requires_not_transitive(): diff --git a/tiramisu/api.py b/tiramisu/api.py index 2600921..932aae4 100644 --- a/tiramisu/api.py +++ b/tiramisu/api.py @@ -871,7 +871,7 @@ class TiramisuContextPermissive(TiramisuContext): @count def get(self): """get configuration permissives""" - self.config_bag.config.cfgimpl_get_settings().get_context_permissive(permissives) + return self.config_bag.config.cfgimpl_get_settings().get_context_permissive() @count def set(self, permissives): @@ -886,7 +886,7 @@ class TiramisuContextPermissive(TiramisuContext): @count def importation(self, permissives): """import configuration permissives""" - return self.config_bag.config.cfgimpl_get_settings()._pp_.importation(permissives) + self.config_bag.config.cfgimpl_get_settings()._pp_.importation(permissives) diff --git a/tiramisu/error.py b/tiramisu/error.py index 46eace1..02637d6 100644 --- a/tiramisu/error.py +++ b/tiramisu/error.py @@ -96,7 +96,8 @@ class PropertiesOptionError(AttributeError): self._requires, self._index, True, - self._config_bag) + self._config_bag, + self._name) #if req != {} or self._orig_opt is not None: if req != {}: only_one = len(req) == 1 diff --git a/tiramisu/setting.py b/tiramisu/setting.py index 82f2da9..09e48cc 100644 --- a/tiramisu/setting.py +++ b/tiramisu/setting.py @@ -376,7 +376,8 @@ class Settings(object): opt.impl_getrequires(), index, False, - config_bag) + config_bag, + opt.impl_get_display_name()) props -= self.getpermissive(opt, path) if apply_requires and config_bag.setting_properties is not None and \ @@ -410,7 +411,7 @@ class Settings(object): index, readable, config_bag, - name=None): + name): """carries out the jit (just in time) requirements between options a requirement is a tuple of this form that comes from the option's @@ -514,7 +515,7 @@ class Settings(object): '').format(name, option.impl_get_display_name(), prop_msg, - display_list(list(properties)))) + display_list(list(properties), add_quote=True))) # transitive action, add action if operator != 'and': if readable: @@ -522,7 +523,8 @@ class Settings(object): err._requires, err._index, True, - err._config_bag).values(): + err._config_bag, + err._name).values(): calc_properties.setdefault(action, []).extend(msg) else: calc_properties.add(action)