Ejemplo n.º 1
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)]
    )
Ejemplo n.º 2
0
def test_raw_field_allow_null():
    field = RawField("field that allows nulls", allow_null=True)

    assert field.from_representation(None) is None
    assert field.from_representation("foo") == "foo"

    assert field.to_representation(None) is None
    assert field.to_representation("foo") == "foo"
Ejemplo n.º 3
0
def test_raw_field(data_type):
    field = RawField(None, None)

    instance = data_type()

    representation = field.to_representation(instance)
    assert isinstance(representation, data_type)
    assert instance == representation

    recreated = field.from_representation(representation)
    assert isinstance(recreated, data_type)
    assert instance == recreated
Ejemplo n.º 4
0
def test_raw_field(data_type):
    field = RawField(None, None)

    instance = data_type()

    representation = field.to_representation(instance)
    assert isinstance(representation, data_type)
    assert instance == representation

    recreated = field.from_representation(representation)
    assert isinstance(recreated, data_type)
    assert instance == recreated
Ejemplo n.º 5
0
class CommitSerializer(BaseSerializer):
    id_loan = RawField("id_loan")
    opcode = RawField("opcode")
    timestamp = RawField("timestamp")
    order = RawField("order")
    proof = RawField("proof")
    address = RawField("address")
    data = RawField("data")
Ejemplo n.º 6
0
class StateSerializer(BaseSerializer):
    id = RawField("id")
    status = RawField("status")
    clock = RawField("clock")
    last_payment = RawField("last payment")
    paid = RawField("paid")
    paid_base = RawField("paid base")
    interest = RawField("interest")
Ejemplo n.º 7
0
class DebtSerializer(BaseSerializer):
    id = RawField("id")
    error = RawField("error")
    balance = RawField("balance")
    model = RawField("model")
    creator = RawField("creator")
    created = RawField("created")
    oracle = RawField("oracle")
Ejemplo n.º 8
0
class DescriptorSerializer(BaseSerializer):
    first_obligation = RawField("first_obligation")
    total_obligation = RawField("total_obligation")
    duration = RawField("duration")
    interest_rate = RawField("interest_rate")
    punitive_interest_rate = RawField("punitive_interest_rate")
    frequency = RawField("frecuency")
    installments = RawField("installments")
Ejemplo n.º 9
0
class DebtWithoutIDSerializer(BaseSerializer):
    error = RawField("error")
    balance = RawField("balance")
    model = RawField("model")
    creator = RawField("creator")
    created = RawField("created")
    oracle = RawField("oracle")
Ejemplo n.º 10
0
def test_raw_field_allow_null():
    field = RawField("field that allows nulls", allow_null=True)

    assert field.from_representation(None) is None
    assert field.from_representation("foo") == "foo"

    assert field.to_representation(None) is None
    assert field.to_representation("foo") == "foo"
Ejemplo n.º 11
0
class URLSerializer(BaseSerializer):
    url = RawField("url", read_only=True)
Ejemplo n.º 12
0
class ConfigSerializer(BaseSerializer):
    id = RawField("id")
    data = RawField("data")
Ejemplo n.º 13
0
class CollateralSerializer(BaseSerializer):
    id = RawField("id")
    debt_id = RawField("debt_id")
    oracle = RawField("oracle")
    token = RawField("token")
    amount = RawField("amount")
    liquidation_ratio = RawField("liquidation_ratio")
    balance_ratio = RawField("balance_ratio")
    burn_fee = RawField("burn_fee")
    reward_fee = RawField("reward_fee")
    owner = RawField("owner")
    amount = RawField("amount")
    status = RawField("status")
Ejemplo n.º 14
0
class OracleHistorySerializer(BaseSerializer):
    id = RawField("id")
    tokens = RawField("discortokens")
    equivalent = RawField("equivalent")
    timestamp = RawField("timestamp")
Ejemplo n.º 15
0
class CompleteLoanSerializer(BaseSerializer):
    id = RawField("id", source="_id")
    open = RawField("open")
    approved = RawField("approved")
    position = RawField("position")
    expiration = RawField("expiration")
    amount = RawField("amount")
    cosigner = RawField("cosigner")
    model = RawField("model")
    creator = RawField("creator")
    oracle = RawField("oracle")
    borrower = RawField("borrower")
    callback = RawField("callback")
    salt = RawField("salt")
    loanData = RawField("loanData")
    created = RawField("created")
    descriptor = ObjectField("descriptor", serializer=DescriptorSerializer())
    currency = RawField("currency")
    lender = RawField("Lender")
    status = RawField("status")
    canceled = RawField("canceled")
    debt = ObjectField("debt", serializer=DebtWithoutIDSerializer())
    config = RawField("config")
    state = ObjectField("state", serializer=StateWithoutIDSerializer())
    collaterals = ListField("collaterals",
                            serializer=CollateralWithoutIDSerializer())
Ejemplo n.º 16
0
class LoanSerializer(BaseSerializer):
    id = RawField("id")
    open = RawField("open")
    approved = RawField("approved")
    position = RawField("position")
    expiration = RawField("expiration")
    amount = RawField("amount")
    cosigner = RawField("cosigner")
    model = RawField("model")
    creator = RawField("creator")
    oracle = RawField("oracle")
    borrower = RawField("borrower")
    callback = RawField("callback")
    salt = RawField("salt")
    loanData = RawField("loanData")
    created = RawField("created")
    descriptor = ObjectField("descriptor", serializer=DescriptorSerializer())
    currency = RawField("currency")
    lender = RawField("Lender")
    status = RawField("status")
    canceled = RawField("canceled")
Ejemplo n.º 17
0
class CatSerializer(BaseSerializer):
    id = IntField("cat identification number", read_only=True)
    name = RawField("cat name", validators=[is_lower_case])
    breed = RawField("official breed name")
Ejemplo n.º 18
0
class CatSerializer(BaseSerializer):
    id = IntField("cat identification number", read_only=True)
    name = RawField("cat name")
    breed = RawField("official breed name")