def test_admin_perms(self, rf): orm_models = self.get_fields_with_perms(rf, ["normal", "inadmin"]) assert "core.NotInAdmin" not in orm_models assert orm_models["core.InAdmin"] == OrmModel( fields=KEYS("admin", "id", "name"), admin=ANY(BaseModelAdmin) ) assert "core.InlineAdmin" not in orm_models assert orm_models["core.Normal"] == OrmModel( fields=KEYS( "admin", "id", "name", "in_admin", "inline_admin", "not_in_admin" ), admin=ANY(BaseModelAdmin), )
def test_all_perms(self, ddb_request): orm_models = self.get_fields_with_perms( ddb_request, ["normal", "notinadmin", "inadmin", "inlineadmin"] ) assert "core.NotInAdmin" not in orm_models assert orm_models["core.InAdmin"] == OrmModel( fields=KEYS("admin", "id", "name"), admin=ANY(BaseModelAdmin), pk="id" ) assert orm_models["core.InlineAdmin"] == OrmModel( fields=KEYS("id", "name", "in_admin"), admin=ANY(BaseModelAdmin), pk="id" ) assert orm_models["core.Normal"] == OrmModel( fields=KEYS( "admin", "id", "name", "in_admin", "inline_admin", "not_in_admin" ), admin=ANY(BaseModelAdmin), pk="id", )
def orm_models(): return { "string": OrmModel(get_fields_for_type(StringType)), "number": OrmModel(get_fields_for_type(NumberType)), "app.model": orm_fields.OrmModel( fields={ "fa": orm_fields.OrmConcreteField( model_name="app.model", name="fa", pretty_name="fa", type_=StringType, rel_name=StringType.name, ), "fd": orm_fields.OrmConcreteField( model_name="app.model", name="fd", pretty_name="fd", type_=StringType, rel_name=StringType.name, ), "fn": orm_fields.OrmCalculatedField( model_name="app.model", name="fn", pretty_name="fn", func=None ), "bob": orm_fields.OrmConcreteField( model_name="app.model", name="bob", pretty_name="bob", type_=StringType, rel_name=StringType.name, ), "num": orm_fields.OrmConcreteField( model_name="app.model", name="num", pretty_name="num", type_=NumberType, rel_name=NumberType.name, ), "tom": orm_fields.OrmFkField( model_name="app.model", name="tom", pretty_name="tom", rel_name="app.Tom", ), }, admin=True, ), "app.Tom": orm_fields.OrmModel( fields={ "jones": orm_fields.OrmConcreteField( model_name="app.Tom", name="jones", pretty_name="jones", type_=StringType, rel_name=StringType.name, ), "michael": orm_fields.OrmFkField( model_name="app.Tom", name="michael", pretty_name="michael", rel_name="app.Michael", ), }, admin=True, ), "app.Michael": orm_fields.OrmModel( fields={ "bolton": orm_fields.OrmConcreteField( model_name="app.Michael", name="bolton", pretty_name="bolton", type_=StringType, rel_name=StringType.name, ) }, admin=True, ), }