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
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 }
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) }
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 }) }
class Env(environment.Environment): properties = { 'DEBUG': schema.Boolean(default=False), 'DATABASE_URL': schema.String(default='sqlite:///test.db'), }
class Env(environment.Environment): properties = { 'DEBUG': schema.Boolean(default=False), 'DATABASE_URL': schema.String }
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.'
class Task(schema.Object): properties = { 'id': schema.Integer(default=None), 'definition': TaskDefinition, 'completed': schema.Boolean(default=False), }
class Env(environment.Environment): properties = { 'DEBUG': schema.Boolean(default=False) }