class Test(Model): computed = Field(type=str, computed='get_hello', computed_empty=True) def get_hello(self): return 'hello'
class Test(Model): computed = Field(type=dict, computed='get_hello', computed_type=True) def get_hello(self): return 'hello'
def test_field_required(self): field = Field(required=True) class Test(Model): test = field self.assertIn(field, Test._required)
def test_field_indexed(self): field = Field(indexed=True) class Test(Model): test = field self.assertIn(field, Test._indexed)
def test_field_model_nested(self): class Beta(Model): pass field = Field(type=Beta) class Alpha(Model): beta = field self.assertIn(field, Alpha._nested)
def test_field_model_related(self): class Beta(Model): pass field = Field(type=Beta, related=True) class Alpha(Model): beta = field self.assertIn(field, Alpha._related)
class Test(Model): field = Field(primary=True)
class Alpha(RethinkDBModel): beta = Field(type=Beta) field = Field(indexed=True)
class Beta(RethinkDBModel): field = Field(indexed=True)
class Test(Model): computed = Field(computed='missing_method')
class Test(Model): computed = Field(computed='value') value = 'test'
class Beta(Model): field = Field()
class Test(Model): computed = Field(computed='method') def method(self): pass
class Test(Model): value = Field() object = Field(type=dict)
class Test(Model): alpha = Field() beta = Field()
class Test(Model): field = Field()
class Beta(Model): gamma = Field(type=Gamma)
class Gamma(Model): field = Field()
class Test(Model): alpha = Field(primary=True) beta = Field(primary=True)
class Alpha(Model): beta = Field(type=Beta)
class Test(Model): computed = Field(type=str, computed=lambda: 'value')
class Beta(Model): value = Field()
class Test(Model): field = Field(required=True)