Exemplo n.º 1
0
    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)
Exemplo n.º 2
0
    class NestedChildView(GenericModelView):
        model = models["child"]
        schema = schemas["child"]

        related = Related(parent=ParentView)

        def put(self, id):
            return self.update(id)
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    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)
Exemplo n.º 5
0
    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)
Exemplo n.º 6
0
    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)
Exemplo n.º 7
0
    class ParentWithCreateView(ParentView):
        related = Related(children=Related(models["child"]))

        def put(self, id):
            return self.update(id)
Exemplo n.º 8
0
    class NestedParentView(ParentView):
        related = Related(children=lambda: ChildView())

        def put(self, id):
            return self.update(id)
Exemplo n.º 9
0
def test_error_combine_related_type_error():
    with pytest.raises(TypeError):
        Related() | {}
Exemplo n.º 10
0
 class ChildWithOtherParentView(ChildView):
     related = ChildView.related | Related(
         other_parent=Related(models["parent"])
     )