add duplicate option to Config
This commit is contained in:
parent
44cd618704
commit
1da83edfba
@ -1,3 +1,7 @@
|
||||
Fri Jul 24 18:03:59 2015 +0200 Emmanuel Garette <egarette@cadoles.com>
|
||||
* add duplicate option to Config, to generate new Config with same
|
||||
value, properties, Option. Option are not duplication.
|
||||
|
||||
Mon Apr 20 14:44:15 2015 +0200 Emmanuel Garette <egarette@cadoles.com>
|
||||
* if option is multi, the properties disallow [None] for a multi but
|
||||
[] too, with allow_empty_list to True, [None] is not allowed, but you
|
||||
|
56
test/test_duplicate_config.py
Normal file
56
test/test_duplicate_config.py
Normal file
@ -0,0 +1,56 @@
|
||||
# coding: utf-8
|
||||
from autopath import do_autopath
|
||||
do_autopath()
|
||||
|
||||
from tiramisu.setting import groups
|
||||
from tiramisu.config import Config
|
||||
from tiramisu.option import ChoiceOption, BoolOption, IntOption, \
|
||||
StrOption, OptionDescription
|
||||
from test.test_state import _diff_opts, _diff_conf
|
||||
from py.test import raises
|
||||
|
||||
|
||||
def make_description():
|
||||
numero_etab = StrOption('numero_etab', "identifiant de l'établissement")
|
||||
nom_machine = StrOption('nom_machine', "nom de la machine", default="eoleng")
|
||||
nombre_interfaces = IntOption('nombre_interfaces', "nombre d'interfaces à activer",
|
||||
default=1)
|
||||
activer_proxy_client = BoolOption('activer_proxy_client', "utiliser un proxy",
|
||||
default=False)
|
||||
mode_conteneur_actif = BoolOption('mode_conteneur_actif', "le serveur est en mode conteneur",
|
||||
default=False)
|
||||
mode_conteneur_actif2 = BoolOption('mode_conteneur_actif2', "le serveur est en mode conteneur2",
|
||||
default=False, properties=('hidden',))
|
||||
|
||||
adresse_serveur_ntp = StrOption('serveur_ntp', "adresse serveur ntp", multi=True)
|
||||
time_zone = ChoiceOption('time_zone', 'fuseau horaire du serveur',
|
||||
('Paris', 'Londres'), 'Paris')
|
||||
|
||||
ip_admin_eth0 = StrOption('ip_admin_eth0', "ip réseau autorisé")
|
||||
netmask_admin_eth0 = StrOption('netmask_admin_eth0', "masque du sous-réseau")
|
||||
|
||||
master = OptionDescription('ip_admin_eth0', '', [ip_admin_eth0, netmask_admin_eth0])
|
||||
interface1 = OptionDescription('interface1', '', [master])
|
||||
interface1.impl_set_group_type(groups.family)
|
||||
|
||||
general = OptionDescription('general', '', [numero_etab, nom_machine,
|
||||
nombre_interfaces, activer_proxy_client,
|
||||
mode_conteneur_actif, mode_conteneur_actif2,
|
||||
adresse_serveur_ntp, time_zone])
|
||||
general.impl_set_group_type(groups.family)
|
||||
new = OptionDescription('new', '', [], properties=('hidden',))
|
||||
new.impl_set_group_type(groups.family)
|
||||
creole = OptionDescription('creole', 'first tiramisu configuration', [general, interface1, new])
|
||||
descr = OptionDescription('baseconfig', 'baseconifgdescr', [creole])
|
||||
return descr
|
||||
|
||||
|
||||
def test_duplicate():
|
||||
cfg = Config(make_description())
|
||||
ncfg = cfg.duplicate()
|
||||
_diff_opts(cfg.cfgimpl_get_description(), ncfg.cfgimpl_get_description())
|
||||
_diff_conf(cfg, ncfg)
|
||||
cfg.creole.general.numero_etab = 'oui'
|
||||
raises(AssertionError, "_diff_conf(cfg, ncfg)")
|
||||
ncfg.creole.general.numero_etab = 'oui'
|
||||
_diff_conf(cfg, ncfg)
|
Loading…
Reference in New Issue
Block a user