Ejemplo n.º 1
0
    def test_construct_pks_no_pks(self):
        """When there are no ids"""
        class MyResource(ResourceBase):
            pks = tuple()

        response = JSONAPIAdapter._construct_id(MyResource())
        self.assertEqual(response, '')
Ejemplo n.º 2
0
    def test_construct_pks_multiple_pks(self):
        """Constructing a single id from multiple"""
        class MyResource(ResourceBase):
            pks = 'id', 'pk'

        response = JSONAPIAdapter._construct_id(MyResource(properties=dict(id=1, pk=2)))
        self.assertEqual(response, '1/2')
Ejemplo n.º 3
0
    def test_construct_pks_one_pk(self):
        """Constructing a single id"""
        class MyResource(ResourceBase):
            pks = 'id',

        response = JSONAPIAdapter._construct_id(MyResource(properties=dict(id=1)))
        self.assertEqual(response, '1')
Ejemplo n.º 4
0
    def test_construct_pks_no_pks(self):
        """When there are no ids"""
        class MyResource(ResourceBase):
            pks = tuple()

        response = JSONAPIAdapter._construct_id(MyResource())
        self.assertEqual(response, '')
Ejemplo n.º 5
0
    def test_construct_pks_multiple_pks(self):
        """Constructing a single id from multiple"""
        class MyResource(ResourceBase):
            pks = 'id', 'pk'

        response = JSONAPIAdapter._construct_id(
            MyResource(properties=dict(id=1, pk=2)))
        self.assertEqual(response, '1/2')
Ejemplo n.º 6
0
    def test_construct_pks_one_pk(self):
        """Constructing a single id"""
        class MyResource(ResourceBase):
            pks = 'id',

        response = JSONAPIAdapter._construct_id(
            MyResource(properties=dict(id=1)))
        self.assertEqual(response, '1')
Ejemplo n.º 7
0
    def test_no_pks_resource_construct_id(self):
        """
        Tests that a response is appropriately returned
        if there are no pks
        """
        class MyResource(ResourceBase):
            pks = 'id',

        res = MyResource(properties=dict(value=1), no_pks=True)
        id_ = JSONAPIAdapter._construct_id(res)
        self.assertEqual(id_, "")
Ejemplo n.º 8
0
    def test_no_pks_resource_construct_id(self):
        """
        Tests that a response is appropriately returned
        if there are no pks
        """
        class MyResource(ResourceBase):
            pks = 'id',

        res = MyResource(properties=dict(value=1), no_pks=True)
        id_ = JSONAPIAdapter._construct_id(res)
        self.assertEqual(id_, "")