# Path: ripozo/resources/relationships/list_relationship.py
# class ListRelationship(Relationship):
#     """
#     Special case for a list of relationships.
#     """
# 
#     def construct_resource(self, properties):
#         """
#         Takes a list of properties and returns a generator that
#         yields Resource instances.  These related ResourceBase subclass
#         will be asked to construct an instance with the keyword argument
#         properties equal to each item in the list of properties provided to
#         this function.
# 
#         :param dict properties: A dictionary of the properties
#             on the parent model.  The list_name provided in the construction
#             of an instance of this class is used to find the list that will be
#             iterated over to generate the resources.
#         :return: A generator that yields the relationships.
#         :rtype: types.GeneratorType
#         """
#         objects = get_or_pop(properties, self.name, [], pop=self.remove_properties)
#         resources = []
#         for obj in objects:
#             res = self.relation(properties=obj, query_args=self.query_args,
#                                 include_relationships=self.embedded)
#             resources.append(res)
#         return resources


from ripozo.resources.relationships.list_relationship import ListRelationship
from ripozo.resources.resource_base import ResourceBase
import unittest2
        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)

    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)

    def test_remove_child_properties(self):
        """
        Test remove child properties
        """
        list_name = 'listname'
        properties = {list_name: 'Something', 'another': 'thing'}

# Path: ripozo/resources/relationships/list_relationship.py
# class ListRelationship(Relationship):
#     """
#     Special case for a list of relationships.
#     """
# 
#     def construct_resource(self, properties):
#         """
#         Takes a list of properties and returns a generator that
#         yields Resource instances.  These related ResourceBase subclass
#         will be asked to construct an instance with the keyword argument
#         properties equal to each item in the list of properties provided to
#         this function.
# 
#         :param dict properties: A dictionary of the properties
#             on the parent model.  The list_name provided in the construction
#             of an instance of this class is used to find the list that will be
#             iterated over to generate the resources.
#         :return: A generator that yields the relationships.
#         :rtype: types.GeneratorType
#         """
#         objects = get_or_pop(properties, self.name, [], pop=self.remove_properties)
#         resources = []
#         for obj in objects:
#             res = self.relation(properties=obj, query_args=self.query_args,
#                                 include_relationships=self.embedded)
#             resources.append(res)
#         return resources


# Path: ripozo_tests/unit/resources/relationships/list_relationship.py
from ripozo.resources.relationships.list_relationship import ListRelationship
from ripozo.resources.resource_base import ResourceBase
import unittest2

        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)

    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)

    def test_remove_child_properties(self):
        """
        Test remove child properties
        """
        list_name = 'listname'
        properties = {list_name: 'Something', 'another': 'thing'}

        lr = ListRelationship(list_name)