예제 #1
0
 def test_validate_integer_type(self):
     v = types.IntegerType(minimum=1, maximum=10)
     v.validate(1)
     v.validate(5)
     v.validate(10)
     self.assertRaises(ValueError, v.validate, 0)
     self.assertRaises(ValueError, v.validate, 11)
예제 #2
0
class DeployStepType(atypes.Base, base.AsDictMixin):
    """A type describing a deployment step."""

    interface = atypes.wsattr(_DEPLOY_INTERFACE_TYPE, mandatory=True)

    step = atypes.wsattr(str, mandatory=True)

    args = atypes.wsattr({str: types.jsontype}, mandatory=True)

    priority = atypes.wsattr(atypes.IntegerType(0), mandatory=True)

    def __init__(self, **kwargs):
        self.fields = ['interface', 'step', 'args', 'priority']
        for field in self.fields:
            value = kwargs.get(field, atypes.Unset)
            setattr(self, field, value)

    def sanitize(self):
        """Removes sensitive data."""
        if self.args != atypes.Unset:
            self.args = strutils.mask_dict_password(self.args, "******")
예제 #3
0
 class ATypeInt(object):
     attr = types.IntegerType(minimum=1, maximum=5)