class TestModel(m.PandoraModel): THE_LIST = [] field1 = m.Field("field1", default="a string") field2 = m.Field("field2", default=THE_LIST) field3 = m.Field("field3", formatter=lambda c, x: x + 1)
class TestModel(m.PandoraModel): class SubModel(m.PandoraModel): field1 = m.Field("field1") THE_LIST = [] field1 = m.Field("field1", default="a string") field2 = m.Field("field2", default=THE_LIST) field3 = m.Field("field3", formatter=lambda c, x: x + 1) field4 = m.Field("field4", model=SubModel) field5 = m.Field("field5", model=SubModel)
class TestModel(m.PandoraListModel): __list_key__ = "field2" __list_model__ = TestSubModel __index_key__ = "idx" field1 = m.Field("field1")
class TestModel(m.PandoraDictListModel): __dict_list_key__ = "fieldD1" __list_key__ = "listKey" __list_model__ = TestSubModel __dict_key__ = "dictKey" field1 = m.Field("field1")
class TestSubModel(m.PandoraModel): idx = m.Field("idx") fieldS1 = m.Field("fieldS1")
def test_defaults(self): field = m.Field("name") self.assertEqual("name", field.field) self.assertIsNone(field.default) self.assertIsNone(field.formatter)
class TestModel(m.with_metaclass(m.ModelMetaClass, object)): foo = "bar" a_field = m.Field("testing") __field__ = m.Field("testing")
class SubModel(m.PandoraModel): field1 = m.Field("field1")