示例#1
0
class Command(MonitorMixin, Resource):
    #: The address to call (without protocol or domain). Eg:
    #: ``/api/<username>/groups/0/action``
    address = fields.String(v.Required())
    #: The body of the request
    body = fields.Dictionary()
    #: The HTTP request method
    method = fields.String(v.In(['GET', 'PUT', 'POST', 'DELETE']))
示例#2
0
class Schedule(MonitorMixin, Resource):
    #: The name of the schedule.
    name = fields.String(v.Required())
    #: Description of the schedule
    description = fields.String()
    #: Command to execute when the scheduled event occurs
    command = fields.Embedded(Command)
    #: Local time when the scheduled event will occur
    local_time = fields.TimePattern(name='localtime')
    #: Status, either 'enabled' or 'disabled'
    status = fields.String(v.In(['enabled', 'disabled']))
    #: If set to true, the schedule will be removed automatically if expired,
    #: if set to false it will be disabled. Default is true.
    auto_delete = fields.Boolean(name='autodelete')
    #: UTC time that the timer was started. Only provided for timers.
    start_time = fields.IsoDate(name='starttime', read_only=True)
示例#3
0
文件: fields.py 项目: makkus/booby
    def __init__(self, *validators, **kwargs):
        self.options = kwargs

        self.default = kwargs.get('default')

        # Setup field validators
        self.validators = []

        if kwargs.get('required'):
            self.validators.append(builtin_validators.Required())

        choices = kwargs.get('choices')

        if choices:
            self.validators.append(builtin_validators.In(choices))

        self.validators.extend(validators)
示例#4
0
    def __init__(self, *validators, **kwargs):
        self.options = kwargs

        self.default = kwargs.get('default')
        self.description = kwargs.get('description', '')
        self.required = kwargs.get('required', False)
        self.choices = kwargs.get('choices', [])

        assert isinstance(self.choices, list)

        # Setup field validators
        self.validators = []

        if self.required:
            self.validators.append(builtin_validators.Required())

        if self.choices:
            self.validators.append(builtin_validators.In(self.choices))

        self.validators.extend(validators)
示例#5
0
 def setup(self):
     self.validator = validators.Required()
示例#6
0
文件: test_list.py 项目: makkus/booby
    def test_should_raise_validation_error_if_field_validator_raise(self):
        self.field = fields.List(validators.Required())

        expect(lambda: self.validate(None)).to(
            raise_error(errors.ValidationError, end_with('required')))
示例#7
0
文件: test_list.py 项目: makkus/booby
    def test_should_pass_if_pass_field_validators(self):
        self.field = fields.List(validators.Required())

        self.validate(['foo', 'bar'])