diff --git a/tests/test_config.py b/tests/test_config.py index d6bfc2f..4b8c2e3 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -12,7 +12,11 @@ import pytest from tiramisu import Config, Calculation, Params, ParamSelfInformation, calc_value from tiramisu.i18n import _ from tiramisu import Config, IntOption, FloatOption, ChoiceOption, \ - BoolOption, StrOption, SymLinkOption, OptionDescription, undefined + BoolOption, StrOption, SymLinkOption, OptionDescription, undefined, \ + DomainnameOption, EmailOption, URLOption, RegexpOption, IPOption, \ + PortOption, NetworkOption, NetmaskOption, BroadcastOption, UsernameOption, \ + GroupnameOption, DateOption, FilenameOption, PasswordOption, MACOption, \ + PermissionsOption from tiramisu.error import ConflictError, ConfigError, PropertiesOptionError @@ -129,6 +133,29 @@ def test_not_valid_properties(): # assert not list_sessions() +def test_information_load(): + ChoiceOption('a', '', ('a', 'b'), informations={'info': 'value'}) + BoolOption('a', '', informations={'info': 'value'}) + IntOption('a', '', informations={'info': 'value'}) + FloatOption('a', '', informations={'info': 'value'}) + StrOption('a', '', informations={'info': 'value'}) + RegexpOption('a', '', informations={'info': 'value'}) + IPOption('a', '', informations={'info': 'value'}) + PortOption('a', '', informations={'info': 'value'}) + NetworkOption('a', '', informations={'info': 'value'}) + NetmaskOption('a', '', informations={'info': 'value'}) + BroadcastOption('a', '', informations={'info': 'value'}) + DomainnameOption('a', '', informations={'info': 'value'}) + EmailOption('a', '', informations={'info': 'value'}) + URLOption('a', '', informations={'info': 'value'}) + UsernameOption('a', '', informations={'info': 'value'}) + GroupnameOption('a', '', informations={'info': 'value'}) + DateOption('a', '', informations={'info': 'value'}) + FilenameOption('a', '', informations={'info': 'value'}) + PasswordOption('a', '', informations={'info': 'value'}) + MACOption('a', '', informations={'info': 'value'}) + PermissionsOption('a', '', informations={'info': 'value'}) + def test_information_config(): od1 = make_description() cfg = Config(od1) diff --git a/tiramisu/option/domainnameoption.py b/tiramisu/option/domainnameoption.py index df888b5..17f6d71 100644 --- a/tiramisu/option/domainnameoption.py +++ b/tiramisu/option/domainnameoption.py @@ -45,17 +45,13 @@ class DomainnameOption(StrOption): def __init__(self, name: str, doc: str, - default: Any=undefined, - default_multi: Any=None, - multi: bool=False, - validators: Optional[List[Calculation]]=None, - properties: Optional[List[str]]=None, - warnings_only: bool=False, + *args, allow_ip: bool=False, allow_cidr_network: bool=False, type: str='domainname', allow_without_dot: bool=False, allow_startswith_dot: bool=False, + **kwargs, ) -> None: # pylint: disable=too-many-branches,too-many-locals,too-many-arguments if type not in ['netbios', 'hostname', 'domainname']: @@ -94,24 +90,23 @@ class DomainnameOption(StrOption): extra['_has_upper'] = re.compile('[A-Z]') if allow_ip: extra['_ip'] = IPOption(name, - doc) + doc, + ) extra['_allow_ip'] = allow_ip if allow_cidr_network: extra['_network'] = NetworkOption(name, doc, - cidr=True) + cidr=True, + ) extra['_allow_cidr_network'] = allow_cidr_network extra['_allow_startswith_dot'] = allow_startswith_dot super().__init__(name, doc, - default=default, - default_multi=default_multi, - multi=multi, - validators=validators, - properties=properties, - warnings_only=warnings_only, - extra=extra) + *args, + extra=extra, + **kwargs, + ) def _get_len(self, type_): if type_ == 'netbios': diff --git a/tiramisu/option/urloption.py b/tiramisu/option/urloption.py index 31bbb8f..47d5820 100644 --- a/tiramisu/option/urloption.py +++ b/tiramisu/option/urloption.py @@ -41,13 +41,7 @@ class URLOption(StrOption): def __init__(self, name: str, doc: str, - default: Any=undefined, - default_multi: Any=None, - multi: bool=False, - validators: Optional[List[Calculation]]=None, - properties: Optional[List[str]]=None, - warnings_only: bool=False, - extra: Optional[Dict]=None, + *args, allow_ip: bool=False, type: str='domainname', allow_without_dot=False, @@ -55,7 +49,9 @@ class URLOption(StrOption): allow_zero: bool=False, allow_wellknown: bool=True, allow_registred: bool=True, - allow_private: bool=False) -> None: + allow_private: bool=False, + **kwargs, + ) -> None: # pylint: disable=too-many-arguments,too-many-locals,redefined-builtin extra = {'_domainname': DomainnameOption(name, doc, @@ -71,13 +67,10 @@ class URLOption(StrOption): allow_private=allow_private)} super().__init__(name, doc, - default=default, - default_multi=default_multi, - multi=multi, - validators=validators, - properties=properties, - warnings_only=warnings_only, - extra=extra) + extra=extra, + *args, + **kwargs, + ) def _get_domain_port_files(self, value: str) -> (str, str):