Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs and tests regarding pagination of empty resources #1463

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ These additional fields are automatically handled by the API (clients don't
need to provide them when adding/editing resources).

The ``_meta`` field provides pagination data and will only be there if
:ref:`Pagination` has been enabled (it is by default) and there is at least one
document being returned. The ``_links`` list provides HATEOAS_ directives.
:ref:`Pagination` has been enabled (it is by default). The ``_links`` list
provides HATEOAS_ directives.

.. _subresources:

Expand Down
5 changes: 5 additions & 0 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ Try requesting ``people`` now:
"href": "/",
"title": "home"
}
},
"_meta": {
"max_results": 25,
"page": 1,
"total": 0
}
}

Expand Down
10 changes: 6 additions & 4 deletions eve/tests/methods/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def test_get_empty_resource(self):
self.assertResourceLink(links, self.empty_resource)
self.assertHomeLink(links)

self.assertPagination(response, 1, 0, 25)

def test_get_max_results(self):
maxr = 10
response, status = self.get(self.known_resource, "?max_results=%d" % maxr)
Expand Down Expand Up @@ -381,7 +383,7 @@ def test_get_projection(self):
self.assertTrue(r[self.app.config["DATE_CREATED"]] != self.epoch)

def test_get_static_projection(self):
""" Test that static projections are honoured """
"""Test that static projections are honoured"""
response, status = self.get(self.different_resource)
self.assert200(status)

Expand Down Expand Up @@ -1279,21 +1281,21 @@ def test_get_idfield_doesnt_exist(self):
self.assert200(status)

def test_get_invalid_idfield_cors(self):
""" test that #381 is fixed. """
"""test that #381 is fixed."""
request = "/%s/badid" % self.known_resource
self.app.config["X_DOMAINS"] = "*"
r = self.test_client.get(request, headers=[("Origin", "test.com")])
self.assert404(r.status_code)

def test_get_invalid_where_syntax(self):
""" test that 'where' syntax with unknown '$' operator returns 400. """
"""test that 'where' syntax with unknown '$' operator returns 400."""
response, status = self.get(
self.known_resource, '?where={"field": {"$foo": "bar"}}'
)
self.assert400(status)

def test_get_invalid_sort_syntax(self):
""" test that invalid sort syntax returns a 400 """
"""test that invalid sort syntax returns a 400"""
response, status = self.get(self.known_resource, '?sort=[("prog":1)]')
self.assert400(status)
response, status = self.get(self.known_resource, '?sort="firstname"')
Expand Down