def test_dehydrate_full_detail_list(self):
        # details path with full_detail=False
        field_1 = ToManyField(SubjectResource, 'subjects', full=True, full_detail=False)
        field_1.instance_name = 'm2m'
        request = MockRequest()
        request.path = {'pk': self.note_1.pk} % "/api/v1/subjects/%(pk)s/"
        bundle_1 = Bundle(obj=self.note_1, request=request)
        self.assertEqual(field_1.dehydrate(bundle_1, for_list=False), ['/api/v1/subjects/1/', '/api/v1/subjects/2/'])

        # list path with full_detail=False
        field_2 = ToManyField(SubjectResource, 'subjects', full=True, full_detail=False)
        field_2.instance_name = 'm2m'
        request = MockRequest()
        request.path = "/api/v1/subjects/"
        bundle_2 = Bundle(obj=self.note_1, request=request)
        subject_bundle_list = field_2.dehydrate(bundle_2)
        self.assertEqual(len(subject_bundle_list), 2)
        self.assertEqual(isinstance(subject_bundle_list[0], Bundle), True)
        self.assertEqual(subject_bundle_list[0].data['name'], u'News')
        self.assertEqual(subject_bundle_list[0].data['url'], u'/news/')
        self.assertEqual(subject_bundle_list[0].obj.name, u'News')
        self.assertEqual(subject_bundle_list[0].obj.url, u'/news/')
        self.assertEqual(isinstance(subject_bundle_list[1], Bundle), True)
        self.assertEqual(subject_bundle_list[1].data['name'], u'Photos')
        self.assertEqual(subject_bundle_list[1].data['url'], u'/photos/')
        self.assertEqual(subject_bundle_list[1].obj.name, u'Photos')
        self.assertEqual(subject_bundle_list[1].obj.url, u'/photos/')

        # list path with full_list=False
        field_3 = ToManyField(SubjectResource, 'subjects', full=True, full_list=False)
        field_3.instance_name = 'm2m'
        request = MockRequest()
        request.path = "/api/v1/subjects/"
        bundle_3 = Bundle(obj=self.note_1, request=request)
        self.assertEqual(field_3.dehydrate(bundle_3), ['/api/v1/subjects/1/', '/api/v1/subjects/2/'])

        # detail path with full_list=False
        field_4 = ToManyField(SubjectResource, 'subjects', full=True, full_list=False)
        field_4.instance_name = 'm2m'
        request = MockRequest()
        request.path = "/api/v1/subjects/%(pk)s/" % {'pk': self.note_1.pk}
        bundle_4 = Bundle(obj=self.note_1, request=request)
        subject_bundle_list = field_4.dehydrate(bundle_4, for_list=False)
        self.assertEqual(len(subject_bundle_list), 2)
        self.assertEqual(isinstance(subject_bundle_list[0], Bundle), True)
        self.assertEqual(subject_bundle_list[0].data['name'], u'News')
        self.assertEqual(subject_bundle_list[0].data['url'], u'/news/')
        self.assertEqual(subject_bundle_list[0].obj.name, u'News')
        self.assertEqual(subject_bundle_list[0].obj.url, u'/news/')
        self.assertEqual(isinstance(subject_bundle_list[1], Bundle), True)
        self.assertEqual(subject_bundle_list[1].data['name'], u'Photos')
        self.assertEqual(subject_bundle_list[1].data['url'], u'/photos/')
        self.assertEqual(subject_bundle_list[1].obj.name, u'Photos')
        self.assertEqual(subject_bundle_list[1].obj.url, u'/photos/')

        # list url with callable returning True
        field_5 = ToManyField(SubjectResource, 'subjects', full=True, full_list=lambda x: True)
        field_5.instance_name = 'm2m'
        request = MockRequest()
        request.path = "/api/v1/subjects/"
        bundle_5 = Bundle(obj=self.note_1, request=request)
        subject_bundle_list = field_5.dehydrate(bundle_5)
        self.assertEqual(len(subject_bundle_list), 2)
        self.assertEqual(isinstance(subject_bundle_list[0], Bundle), True)
        self.assertEqual(subject_bundle_list[0].data['name'], u'News')
        self.assertEqual(subject_bundle_list[0].data['url'], u'/news/')
        self.assertEqual(subject_bundle_list[0].obj.name, u'News')
        self.assertEqual(subject_bundle_list[0].obj.url, u'/news/')
        self.assertEqual(isinstance(subject_bundle_list[1], Bundle), True)
        self.assertEqual(subject_bundle_list[1].data['name'], u'Photos')
        self.assertEqual(subject_bundle_list[1].data['url'], u'/photos/')
        self.assertEqual(subject_bundle_list[1].obj.name, u'Photos')
        self.assertEqual(subject_bundle_list[1].obj.url, u'/photos/')

        # list url with callable returning False
        field_6 = ToManyField(SubjectResource, 'subjects', full=True, full_list=lambda x: False)
        field_6.instance_name = 'm2m'
        request = MockRequest()
        request.path = "/api/v1/subjects/"
        bundle_6 = Bundle(obj=self.note_1, request=request)
        self.assertEqual(field_6.dehydrate(bundle_6), ['/api/v1/subjects/1/', '/api/v1/subjects/2/'])

        # detail url with callable returning True
        field_7 = ToManyField(SubjectResource, 'subjects', full=True, full_detail=lambda x: True)
        field_7.instance_name = 'm2m'
        request = MockRequest()
        request.path = "/api/v1/subjects/%(pk)s/" % {'pk': self.note_1.pk}
        bundle_7 = Bundle(obj=self.note_1, request=request)
        subject_bundle_list = field_7.dehydrate(bundle_7)
        self.assertEqual(len(subject_bundle_list), 2)
        self.assertEqual(isinstance(subject_bundle_list[0], Bundle), True)
        self.assertEqual(subject_bundle_list[0].data['name'], u'News')
        self.assertEqual(subject_bundle_list[0].data['url'], u'/news/')
        self.assertEqual(subject_bundle_list[0].obj.name, u'News')
        self.assertEqual(subject_bundle_list[0].obj.url, u'/news/')
        self.assertEqual(isinstance(subject_bundle_list[1], Bundle), True)
        self.assertEqual(subject_bundle_list[1].data['name'], u'Photos')
        self.assertEqual(subject_bundle_list[1].data['url'], u'/photos/')
        self.assertEqual(subject_bundle_list[1].obj.name, u'Photos')
        self.assertEqual(subject_bundle_list[1].obj.url, u'/photos/')

        # detail url with callable returning False
        field_8 = ToManyField(SubjectResource, 'subjects', full=True, full_detail=lambda x: False)
        field_8.instance_name = 'm2m'
        request = MockRequest()
        request.path = "/api/v1/subjects/%(pk)s/" % {'pk': self.note_1.pk}
        bundle_8 = Bundle(obj=self.note_1, request=request)
        self.assertEqual(field_8.dehydrate(bundle_8, for_list=False), ['/api/v1/subjects/1/', '/api/v1/subjects/2/'])

        # detail url with full_detail=True and get parameters
        field_9 = ToManyField(SubjectResource, 'subjects', full=True, full_detail=True)
        field_9.instance_name = 'm2m'
        request = HttpRequest()
        request.method = "GET"
        request.GET = {"foo": "bar"}
        request.META["QUERY_STRING"] = "foo=bar"
        request.path = "/api/v1/subjects/%(pk)s/" % {'pk': self.note_1.pk}
        bundle_9 = Bundle(obj=self.note_1, request=request)
        subject_bundle_list = field_9.dehydrate(bundle_9)
        self.assertEqual(len(subject_bundle_list), 2)
        self.assertEqual(isinstance(subject_bundle_list[0], Bundle), True)
        self.assertEqual(subject_bundle_list[0].data['name'], u'News')
        self.assertEqual(subject_bundle_list[0].data['url'], u'/news/')
        self.assertEqual(subject_bundle_list[0].obj.name, u'News')
        self.assertEqual(subject_bundle_list[0].obj.url, u'/news/')
        self.assertEqual(isinstance(subject_bundle_list[1], Bundle), True)
        self.assertEqual(subject_bundle_list[1].data['name'], u'Photos')
        self.assertEqual(subject_bundle_list[1].data['url'], u'/photos/')
        self.assertEqual(subject_bundle_list[1].obj.name, u'Photos')
        self.assertEqual(subject_bundle_list[1].obj.url, u'/photos/')
dataset/ETHPy150Open django-tastypie/django-tastypie/tests/core/tests/fields.py/ToManyFieldTestCase.test_dehydrate_full_detail_list/swapped operands of `%`