Merge branch 'master' into orm
authorEmmanuel Garette <egarette@cadoles.com>
Thu, 6 Feb 2014 21:21:22 +0000 (22:21 +0100)
committerEmmanuel Garette <egarette@cadoles.com>
Thu, 6 Feb 2014 21:24:50 +0000 (22:24 +0100)
Conflicts:
test/test_option_consistency.py
test/test_state.py
tiramisu/option.py

1  2 
test/test_config_api.py
test/test_option_consistency.py
tiramisu/option.py

Simple merge
@@@ -277,7 -274,21 +291,21 @@@ def test_consistency_broadcast()
      c.c[1] = '192.168.2.255'
  
  
 -def test_consistency_broadcast_default():
+ def test_consistency_broadcast_error():
+     a = NetworkOption('a', '', multi=True)
+     b = NetmaskOption('b', '', multi=True)
+     c = BroadcastOption('c', '', multi=True)
+     od = OptionDescription('a', '', [a, b, c])
+     od.impl_set_group_type(groups.master)
+     b.impl_add_consistency('network_netmask', a)
+     c.impl_add_consistency('broadcast', a)
+     c = Config(od)
+     c.a = ['192.168.1.0']
+     c.b = ['255.255.255.0']
+     raises(ConfigError, "c.c = ['192.168.1.255']")
 +def test_consistency_broadcast_default_1():
      a = NetworkOption('a', '', '192.168.1.0')
      b = NetmaskOption('b', '', '255.255.255.128')
      c = BroadcastOption('c', '', '192.168.2.127')
@@@ -920,11 -852,10 +902,11 @@@ class PortOption(Option)
  
          for val in value:
              try:
 -                if not self._min_value <= int(val) <= self._max_value:
 +                if not self._extra['_min_value'] <= int(val) <= self._extra['_max_value']:
-                     raise ValueError('invalid port, must be an between {0} '
-                                      'and {1}'.format(
+                     raise ValueError(_('invalid port, must be an between {0} '
 -                                     'and {1}').format(self._min_value,
 -                                                       self._max_value))
++                                     'and {1}').format(
 +                                         self._extra['_min_value'],
 +                                         self._extra['_max_value']))
              except ValueError:
                  raise ValueError(_('invalid port'))
  
@@@ -989,12 -920,10 +968,10 @@@ class NetmaskOption(Option)
                                  " this IP is a network")
  
          except ValueError:
-             if make_net:
-                 msg = _('invalid IP {0} ({1}) with netmask {2}')
-             else:
+             if not make_net:
                  msg = _('invalid network {0} ({1}) with netmask {2}')
          if msg is not None:
 -            raise ValueError(msg.format(val_ipnetwork, opts[1]._name,
 +            raise ValueError(msg.format(val_ipnetwork, opts[1].impl_getname(),
                                          val_netmask))
  
  
@@@ -1077,11 -1008,11 +1054,11 @@@ class DomainnameOption(Option)
                  return
              except ValueError:
                  pass
 -        if self._type == 'domainname' and not self._allow_without_dot and \
 +        if self._dom_type == 'domainname' and not self._allow_without_dot and \
                  '.' not in value:
              raise ValueError(_("invalid domainname, must have dot"))
-             if len(value) > 255:
-                 raise ValueError(_("invalid domainname's length (max 255)"))
+         if len(value) > 255:
+             raise ValueError(_("invalid domainname's length (max 255)"))
          if len(value) < 2:
              raise ValueError(_("invalid domainname's length (min 2)"))
          if not self._domain_re.search(value):
@@@ -1338,17 -1289,11 +1315,14 @@@ class OptionDescription(BaseOption, Sto
          if consistencies is not None:
              for func, all_cons_opts in consistencies:
                  #all_cons_opts[0] is the option where func is set
-                 ret = all_cons_opts[0]._launch_consistency(func, option,
-                                                            value,
-                                                            context, index,
-                                                            all_cons_opts)
-                 if ret is False:
-                     return False
-         return True
+                 all_cons_opts[0]._launch_consistency(func, option,
+                                                      value,
+                                                      context, index,
+                                                      all_cons_opts)
  
 +    # ____________________________________________________________
 +    # serialize object
 +
      def _impl_getstate(self, descr=None):
          """enables us to export into a dict
          :param descr: parent :class:`tiramisu.option.OptionDescription`