def test_model_instance_serialize(self): items = [ContentType.objects.all()[0]] view = MockResourceView(items) adaptor = CollectionJSON(view) response = adaptor.serialize(instance=items[0], content_type='application/vnd.Collection.next+JSON') data = json.loads(response.content) json_items = data['collection']['items'] self.assertEqual(len(json_items), 1)
def test_application_resource_serialize(self): app_resource = ApplicationResource(site=site, app_name='testapp') items = [app_resource] view = MockResourceView(items) adaptor = CollectionJSON(view) response = adaptor.serialize(content_type='application/vnd.Collection.next+JSON') data = json.loads(response.content) json_items = data['collection']['items']
def test_queryset_serialize(self): items = ContentType.objects.all() view = MockResourceView(items) adaptor = CollectionJSON(view) response = adaptor.serialize(content_type='application/vnd.Collection.next+JSON') data = json.loads(response.content) json_items = data['collection']['items'] self.assertEqual(len(json_items), len(items))