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, '')
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')
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')
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, '')
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')
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')
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_, "")
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_, "")