Esempio n. 1
0
    def test_model_cls_could_not_be_rebound(self):
        """Test that field model class could not be rebound."""
        class Model(models.DomainModel):
            """Test model."""

        field = fields.Field()

        field.bind_model_cls(Model)
        with self.assertRaises(errors.Error):
            field.bind_model_cls(Model)
Esempio n. 2
0
class ExampleModel(models.DomainModel):
    """Example model."""

    field = fields.Field()
    field_default = fields.Field(default=123)
    field_default_callable = fields.Field(default=time.time)
    field_required_default = fields.Field(default=123, required=True)

    bool_field = fields.Bool()

    int_field = fields.Int()
    float_field = fields.Float()

    string_field = fields.String()
    binary_field = fields.Binary()

    date_field = fields.Date()
    datetime_field = fields.DateTime()

    model_field = fields.Model(RelatedModel)
    collection_field = fields.Collection(RelatedModel)
Esempio n. 3
0
class RequiredFieldModel(models.DomainModel):
    """Example model for required fields."""
    field_required = fields.Field(required=True)
Esempio n. 4
0
            class Model(models.DomainModel):
                """Test model."""

                __view_key__ = fields.Field()
Esempio n. 5
0
            class Model(models.DomainModel):
                """Test model."""

                __unique_key__ = fields.Field()
Esempio n. 6
0
        class Model(models.DomainModel):
            """Test model."""

            field = fields.Field()
            __slots_optimization__ = False
Esempio n. 7
0
        class Model(models.DomainModel):
            """Test model."""

            field = fields.Field()