0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-12-01 11:41:20 +01:00

Revert "feat(api/2): Removed meta from top of listings"

This reverts commit fb61033d9ffc5f460a3fa3704a8b13350b25dd03.
This commit is contained in:
Karl Hobley 2016-02-24 08:47:24 +00:00
parent 858e97d95d
commit 3cc0662d42
4 changed files with 34 additions and 20 deletions

View File

@ -37,7 +37,9 @@ class WagtailPagination(BasePagination):
def get_paginated_response(self, data):
data = OrderedDict([
('total_count', self.total_count),
('meta', OrderedDict([
('total_count', self.total_count),
])),
('items', data),
])
return Response(data)

View File

@ -31,10 +31,14 @@ class TestDocumentListing(TestCase):
# Will crash if the JSON is invalid
content = json.loads(response.content.decode('UTF-8'))
# Check that the meta section is there
self.assertIn('meta', content)
self.assertIsInstance(content['meta'], dict)
# Check that the total count is there and correct
self.assertIn('total_count', content)
self.assertIsInstance(content['total_count'], int)
self.assertEqual(content['total_count'], Document.objects.count())
self.assertIn('total_count', content['meta'])
self.assertIsInstance(content['meta']['total_count'], int)
self.assertEqual(content['meta']['total_count'], Document.objects.count())
# Check that the items section is there
self.assertIn('items', content)
@ -189,7 +193,7 @@ class TestDocumentListing(TestCase):
content = json.loads(response.content.decode('UTF-8'))
# The total count must not be affected by "limit"
self.assertEqual(content['total_count'], Document.objects.count())
self.assertEqual(content['meta']['total_count'], Document.objects.count())
def test_limit_not_integer_gives_error(self):
response = self.get_response(limit='abc')
@ -242,7 +246,7 @@ class TestDocumentListing(TestCase):
content = json.loads(response.content.decode('UTF-8'))
# The total count must not be affected by "offset"
self.assertEqual(content['total_count'], Document.objects.count())
self.assertEqual(content['meta']['total_count'], Document.objects.count())
def test_offset_not_integer_gives_error(self):
response = self.get_response(offset='abc')

View File

@ -31,10 +31,14 @@ class TestImageListing(TestCase):
# Will crash if the JSON is invalid
content = json.loads(response.content.decode('UTF-8'))
# Check that the meta section is there
self.assertIn('meta', content)
self.assertIsInstance(content['meta'], dict)
# Check that the total count is there and correct
self.assertIn('total_count', content)
self.assertIsInstance(content['total_count'], int)
self.assertEqual(content['total_count'], get_image_model().objects.count())
self.assertIn('total_count', content['meta'])
self.assertIsInstance(content['meta']['total_count'], int)
self.assertEqual(content['meta']['total_count'], get_image_model().objects.count())
# Check that the items section is there
self.assertIn('items', content)
@ -187,7 +191,7 @@ class TestImageListing(TestCase):
content = json.loads(response.content.decode('UTF-8'))
# The total count must not be affected by "limit"
self.assertEqual(content['total_count'], get_image_model().objects.count())
self.assertEqual(content['meta']['total_count'], get_image_model().objects.count())
def test_limit_not_integer_gives_error(self):
response = self.get_response(limit='abc')
@ -240,7 +244,7 @@ class TestImageListing(TestCase):
content = json.loads(response.content.decode('UTF-8'))
# The total count must not be affected by "offset"
self.assertEqual(content['total_count'], get_image_model().objects.count())
self.assertEqual(content['meta']['total_count'], get_image_model().objects.count())
def test_offset_not_integer_gives_error(self):
response = self.get_response(offset='abc')

View File

@ -40,10 +40,14 @@ class TestPageListing(TestCase):
# Will crash if the JSON is invalid
content = json.loads(response.content.decode('UTF-8'))
# Check that the meta section is there
self.assertIn('meta', content)
self.assertIsInstance(content['meta'], dict)
# Check that the total count is there and correct
self.assertIn('total_count', content)
self.assertIsInstance(content['total_count'], int)
self.assertEqual(content['total_count'], get_total_page_count())
self.assertIn('total_count', content['meta'])
self.assertIsInstance(content['meta']['total_count'], int)
self.assertEqual(content['meta']['total_count'], get_total_page_count())
# Check that the items section is there
self.assertIn('items', content)
@ -63,7 +67,7 @@ class TestPageListing(TestCase):
response = self.get_response()
content = json.loads(response.content.decode('UTF-8'))
self.assertEqual(content['total_count'], total_count - 1)
self.assertEqual(content['meta']['total_count'], total_count - 1)
def test_private_pages_dont_appear_in_list(self):
total_count = get_total_page_count()
@ -76,7 +80,7 @@ class TestPageListing(TestCase):
response = self.get_response()
content = json.loads(response.content.decode('UTF-8'))
self.assertEqual(content['total_count'], new_total_count)
self.assertEqual(content['meta']['total_count'], new_total_count)
# TYPE FILTER
@ -95,8 +99,8 @@ class TestPageListing(TestCase):
response = self.get_response(type='demosite.BlogEntryPage')
content = json.loads(response.content.decode('UTF-8'))
# Total count must be reduced as this filters the items
self.assertEqual(content['total_count'], 3)
# Total count must be reduced as this filters the results
self.assertEqual(content['meta']['total_count'], 3)
def test_type_filter_multiple(self):
response = self.get_response(type='demosite.BlogEntryPage,demosite.EventPage')
@ -448,7 +452,7 @@ class TestPageListing(TestCase):
content = json.loads(response.content.decode('UTF-8'))
# The total count must not be affected by "limit"
self.assertEqual(content['total_count'], get_total_page_count())
self.assertEqual(content['meta']['total_count'], get_total_page_count())
def test_limit_not_integer_gives_error(self):
response = self.get_response(limit='abc')
@ -501,7 +505,7 @@ class TestPageListing(TestCase):
content = json.loads(response.content.decode('UTF-8'))
# The total count must not be affected by "offset"
self.assertEqual(content['total_count'], get_total_page_count())
self.assertEqual(content['meta']['total_count'], get_total_page_count())
def test_offset_not_integer_gives_error(self):
response = self.get_response(offset='abc')