class NestedParentView(ParentView): related = Related(children=Related(models['child']), ) def get(self, id): return self.retrieve(id) def put(self, id): return self.update(id, return_content=True)
class NestedChildView(GenericModelView): model = models["child"] schema = schemas["child"] related = Related(parent=ParentView) def put(self, id): return self.update(id)
class ParentView(GenericModelView): model = models["parent"] schema = schemas["parent"] related = Related(children=RelatedId(lambda: ChildView(), "child_ids")) def get(self, id): return self.retrieve(id) def put(self, id): return self.update(id)
class ChildView(GenericModelView): model = models['child'] schema = schemas['child'] related = Related(parent=ParentView, ) def get(self, id): return self.retrieve(id) def put(self, id): return self.update(id, return_content=True)
class ParentView(GenericModelView): model = models['parent'] schema = schemas['parent'] related = Related(children=lambda: ChildView(), ) def get(self, id): return self.retrieve(id) def put(self, id): return self.update(id, return_content=True)
class ChildView(GenericModelView): model = models["child"] schema = schemas["child"] base_query_options = (raiseload("*"),) related = Related(parent=RelatedId(ParentView, "parent_id")) def get(self, id): return self.retrieve(id) def put(self, id): return self.update(id)
class ParentWithCreateView(ParentView): related = Related(children=Related(models["child"])) def put(self, id): return self.update(id)
class NestedParentView(ParentView): related = Related(children=lambda: ChildView()) def put(self, id): return self.update(id)
def test_error_combine_related_type_error(): with pytest.raises(TypeError): Related() | {}
class ChildWithOtherParentView(ChildView): related = ChildView.related | Related( other_parent=Related(models["parent"]) )