Ejemplo n.º 1
0
def test_boolean():
    assert schema.Boolean(1) is True
    assert schema.Boolean(0) is False
    assert schema.Boolean('1') is True
    assert schema.Boolean('0') is False
    assert schema.Boolean(True) is True
    assert schema.Boolean(False) is False
    assert schema.Boolean('TRUE') is True
    assert schema.Boolean('FALSE') is False
Ejemplo n.º 2
0
class MatrixDescriptor(schema.Object):
    """
    Describes the options to create a term document matrix.
    """
    properties = {
        'bibliography': schema.String(max_length=40),
        'regularise': schema.Boolean(default=True),
        'fields': MatrixFields
    }
Ejemplo n.º 3
0
class Env(environment.Environment):
    """
    Environment variables wrapper
    """
    properties = {
        'DEBUG': schema.Boolean(default=False),
        'DATABASE_URL': schema.String(default='sqlite:///timetable.db'),
        'ATTEMPTS': schema.Integer(default=1)
    }
Ejemplo n.º 4
0
class HighScore(schema.Object):
    properties = {
        'name': schema.String(max_length=100),
        'score': schema.Integer(minimum=0, maximum=100),
        'completed': schema.Boolean(default=False),
        'difficulty': schema.Enum(enum=['easy', 'medium', 'hard']),
        'location': Location(default={
            'latitude': 0.0,
            'longitude': 0.0
        })
    }
Ejemplo n.º 5
0
class Env(environment.Environment):
    properties = {
        'DEBUG': schema.Boolean(default=False),
        'DATABASE_URL': schema.String(default='sqlite:///test.db'),
    }
Ejemplo n.º 6
0
class Env(environment.Environment):
    properties = {
        'DEBUG': schema.Boolean(default=False),
        'DATABASE_URL': schema.String
    }
Ejemplo n.º 7
0
def test_boolean_kwargs():
    CustomBool = schema.Boolean(errors={'type': 'Must be true or false.'})
    with pytest.raises(exceptions.SchemaError) as exc:
        CustomBool('invalid')
    assert str(exc.value) == 'Must be true or false.'
Ejemplo n.º 8
0
class Task(schema.Object):
    properties = {
        'id': schema.Integer(default=None),
        'definition': TaskDefinition,
        'completed': schema.Boolean(default=False),
    }
Ejemplo n.º 9
0
class Env(environment.Environment):
    properties = {
        'DEBUG': schema.Boolean(default=False)
    }