Ejemplo n.º 1
0
    def test_format_request_relationships(self):
        """
        Tests that relationships are appropriately reformatted
        to the ripozo style.
        """
        class RelatedResource(ResourceBase):
            pks = ('id', 'pk',)

        rel_dict = {'resource': dict(data=dict(id='1/2', type='related_resource'))}
        req = RequestContainer(body_args=dict(data=dict(attributes=dict(id=1), relationships=rel_dict)))
        resp = JSONAPIAdapter.format_request(req)
        self.assertDictEqual(resp.body_args, {'id': 1, 'resource.id': '1', 'resource.pk': '2'})
Ejemplo n.º 2
0
    def test_format_request_relationships(self):
        """
        Tests that relationships are appropriately reformatted
        to the ripozo style.
        """

        class RelatedResource(ResourceBase):
            pks = ("id", "pk")

        rel_dict = {"resource": dict(data=dict(id="1/2", type="related_resource"))}
        req = RequestContainer(body_args=dict(data=dict(attributes=dict(id=1), relationships=rel_dict)))
        resp = JSONAPIAdapter.format_request(req)
        self.assertDictEqual(resp.body_args, {"id": 1, "resource.id": "1", "resource.pk": "2"})
Ejemplo n.º 3
0
    def test_format_request_relationships(self):
        """
        Tests that relationships are appropriately reformatted
        to the ripozo style.
        """
        class RelatedResource(ResourceBase):
            pks = (
                'id',
                'pk',
            )

        rel_dict = {
            'resource': dict(data=dict(id='1/2', type='related_resource'))
        }
        req = RequestContainer(body_args=dict(
            data=dict(attributes=dict(id=1), relationships=rel_dict)))
        resp = JSONAPIAdapter.format_request(req)
        self.assertDictEqual(resp.body_args, {
            'id': 1,
            'resource.id': '1',
            'resource.pk': '2'
        })
Ejemplo n.º 4
0
 def test_format_request(self):
     """Expected case"""
     req = RequestContainer(body_args=dict(data=dict(attributes=dict(
         id=1))))
     resp = JSONAPIAdapter.format_request(req)
     self.assertDictEqual(resp.body_args, dict(id=1))
Ejemplo n.º 5
0
 def test_format_request(self):
     """Expected case"""
     req = RequestContainer(body_args=dict(data=dict(attributes=dict(id=1))))
     resp = JSONAPIAdapter.format_request(req)
     self.assertDictEqual(resp.body_args, dict(id=1))