示例#1
0
class ProjectResourceSerializer(ZopsBaseSerializer):
    name = StringField("Project name.Max length 70 Character")
    description = StringField("Project description.Max length 200 Character")
    id = StringField("ID", read_only=True)
    userLimit = IntField("User limit of service.", read_only=True, source='user_limit')
    userUsed = IntField("User used of service.", read_only=True, source='user_used')
    services = ZopsListOfStringsField("Project's active services", read_only=True)
示例#2
0
class ServiceSerializer(ZopsBaseSerializer):
    id = StringField("ID", read_only=True)
    itemLimit = IntField("Item limit of service.",
                         read_only=True,
                         source='item_limit')
    itemUsed = IntField("Item used of service.",
                        read_only=True,
                        source='item_used')
    name = StringField("Service name.Max length 70 Character")
    description = StringField("Service description.Max length 200 Character")
    serviceCatalogCode = StringField("Code name of the service.",
                                     validators=[is_service_code],
                                     source="service_catalog_code")
示例#3
0
class SubscriptionSerializer(BaseSerializer):
    #TODO: ADD VALIDATORS
    email = StringField("Email to send repository reports")
    subscriptions = JsonField("List of subscribed github ids")
    period = StringField("Notification period e.g. daily, or weekly")
    telegramID = StringField("Telegram ID")
    repoCount = IntField("Number of suggestions each time")
示例#4
0
class ExampleSerializer(BaseSerializer):
    writable = RawField("testing writable field")
    readonly = RawField("testing readonly field", read_only=True)
    unsigned = IntField(
        "testing validated field",
        validators=[min_validator(0)]
    )
示例#5
0
class MeLastReadMessageSerializer(ZopsBaseDBSerializer):
    lastReadMessageId = ZopsAlphaNumericStringField(
        "Unique identifier of the message")
    numberOfUnreadMessage = IntField("Number of unread message",
                                     source="number_of_unread_message",
                                     read_only=True)
示例#6
0
class CatSerializer(BaseSerializer):
    id = IntField("cat identification number", read_only=True)
    name = StringField("cat name", validators=[is_lower_case])
    breed = StringField("official breed name")
示例#7
0
def test_int_field():
    field = IntField("test int field", max_value=100, min_value=0)

    # note: constraints (validators) does not affect conversions
    # between internal value and representation and this is fine
    # because we need to have value converted from representation
    # to be able to do validation
    assert field.from_representation(123) == 123
    assert field.from_representation('123') == 123
    assert field.to_representation(123) == 123
    assert field.to_representation('123') == 123

    # accept only explicit integers
    with pytest.raises(ValueError):
        field.to_representation('123.0213')
    with pytest.raises(ValueError):
        field.from_representation('123.0213')

    # accept only numbers
    with pytest.raises(ValueError):
        field.to_representation('foo')
    with pytest.raises(ValueError):
        field.from_representation('foo')

    # test validation
    with pytest.raises(ValidationError):
        field.validate(-10)
    with pytest.raises(ValidationError):
        field.validate(123)
示例#8
0
def test_int_field():
    field = IntField("test int field", max_value=100, min_value=0)

    # note: constraints (validators) does not affect conversions
    # between internal value and representation and this is fine
    # because we need to have value converted from representation
    # to be able to do validation
    assert field.from_representation(123) == 123
    assert field.from_representation('123') == 123
    assert field.to_representation(123) == 123
    assert field.to_representation('123') == 123

    # accept only explicit integers
    with pytest.raises(ValueError):
        field.to_representation('123.0213')
    with pytest.raises(ValueError):
        field.from_representation('123.0213')

    # accept only numbers
    with pytest.raises(ValueError):
        field.to_representation('foo')
    with pytest.raises(ValueError):
        field.from_representation('foo')

    # test validation
    with pytest.raises(ValidationError):
        field.validate(-10)
    with pytest.raises(ValidationError):
        field.validate(123)
示例#9
0
class CollateralCountSerializer(BaseSerializer):
    count = IntField("State count")
示例#10
0
class CommitCountSerializer(BaseSerializer):
    count = IntField("State count")
示例#11
0
class ConfigCountSerializer(BaseSerializer):
    count = IntField("Config count")
示例#12
0
class DebtCountSerializer(BaseSerializer):
    count = IntField("Debt count")
示例#13
0
class LoanCountSerializer(BaseSerializer):
    count = IntField("Loan count")
示例#14
0
class CatSerializer(BaseSerializer):
    id = IntField("cat identification number", read_only=True)
    name = RawField("cat name")
    breed = RawField("official breed name")