示例#1
0
 def test_empty_list(self,):
     class RelatedResource2(ResourceBase):
         pass
     list_name = 'mylist'
     lr = ListRelationship(list_name, relation='RelatedResource')
     res_list = lr.construct_resource(dict(some='thing', another='thing'))
     self.assertIsInstance(res_list, list)
     self.assertEqual(len(res_list), 0)
示例#2
0
    def test_construct_resource(self):
        class RelatedResource(ResourceBase):
            _pks = ['pk']

        list_name = 'mylist'
        lr = ListRelationship(list_name, relation='RelatedResource')
        props = {list_name: []}
        for i in range(10):
            props[list_name].append(dict(pk=i))
        res_list = lr.construct_resource(props)
        self.assertIsInstance(res_list, list)
        for x in res_list:
            # TODO actually check this
            pass
        self.assertEqual(len(res_list), 10)