Exemplo n.º 1
0
class ConfigSchema(Schema):
    heartbeats = fields.List(fields.Nested(HeartbeatSchema),
                             required=False,
                             missing=[])
    ip = fields.IPv4(required=True)
    listeners = fields.List(fields.Nested(ListenerSchema),
                            required=False,
                            missing=[])
    logging = fields.List(fields.Nested(LoggingSchema),
                          required=False,
                          missing=[])
    notifiers = fields.List(fields.Nested(NotifierSchema),
                            required=False,
                            missing=[])
    partitions = fields.Mapping(
        keys=fields.String(required=True),
        values=fields.String(required=True),
        required=True,
    )
    password = fields.String(missing="")
    port = fields.Integer(required=False, missing=4025)
    storage = fields.List(fields.Nested(StorageSchema),
                          required=False,
                          missing=[])
    zones = fields.Mapping(
        keys=fields.String(required=True),
        values=fields.String(required=True),
        required=True,
    )

    @post_load
    def make_config(self, data, **kwargs):
        return Config(**data)
Exemplo n.º 2
0
class ServerSchema(Schema):
    id = fields.Int(dump_only=True)
    ip = fields.IPv4()
    port = fields.Int()
    nickname = fields.Str()

    @post_load
    def make_server(self, data, **kwargs):
        return Server(**data)
Exemplo n.º 3
0
    def test_ipv4_address_field(self, user):

        ipv4_string = "192.168.0.1"

        user.ipv4 = ipaddress.ip_address(ipv4_string)
        user.empty_ip = None

        field = fields.IPv4()
        assert isinstance(field.serialize("ipv4", user), str)
        assert field.serialize("ipv4", user) == ipv4_string
        assert field.serialize("empty_ip", user) is None
Exemplo n.º 4
0
class PaymentSchema(Schema):
    createdAt = fields.DateTime()
    merchantCode = fields.Str()
    customerCode = fields.Str()
    token = fields.Str()
    ip = fields.IPv4()
    amount = fields.Decimal()
    currency = fields.Str()
    status = fields.Str()
    orderId = fields.UUID()
    bankTransactionId = fields.Str()
    gatewayResponseCode = fields.Str()
    errorCode = fields.Str(required=False)

    @post_load
    def load_model(self, data, **kwargs):
        return Payment(**data, response=data)