Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix #423: Expose the 'more_results' value fetched from the back-end.#425
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -51,10 +51,12 @@ def test__clone(self): | ||
| _DATASET = 'DATASET' | ||
| _KIND = 'KIND' | ||
| _CURSOR = 'DEADBEEF' | ||
| _MORE_RESULTS = 2 | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| _NAMESPACE = 'NAMESPACE' | ||
| dataset = Dataset(_DATASET) | ||
| query = self._makeOne(_KIND, dataset, _NAMESPACE) | ||
| query._cursor = _CURSOR | ||
| query._more_results = _MORE_RESULTS | ||
| clone = query._clone() | ||
| self.assertFalse(clone is query) | ||
| self.assertTrue(isinstance(clone, self._getTargetClass())) | ||
| @@ -63,6 +65,7 @@ def test__clone(self): | ||
| kq_pb, = list(clone.kind()) | ||
| self.assertEqual(kq_pb.name, _KIND) | ||
| self.assertEqual(clone._cursor, _CURSOR) | ||
| self.assertEqual(clone._more_results, _MORE_RESULTS) | ||
| def test_to_protobuf_empty(self): | ||
| query = self._makeOne() | ||
| @@ -317,6 +320,7 @@ def test_fetch_default_limit(self): | ||
| self.assertEqual(connection._called_with, expected_called_with) | ||
| def test_fetch_explicit_limit(self): | ||
| import base64 | ||
| from gcloud.datastore.datastore_v1_pb2 import Entity | ||
| _CURSOR = 'CURSOR' | ||
| _DATASET = 'DATASET' | ||
| @@ -336,7 +340,8 @@ def test_fetch_explicit_limit(self): | ||
| query = self._makeOne(_KIND, dataset, _NAMESPACE) | ||
| limited = query.limit(13) | ||
| entities = query.fetch(13) | ||
| self.assertEqual(query._cursor, _CURSOR) | ||
| self.assertEqual(query.cursor(), base64.b64encode(_CURSOR)) | ||
| self.assertEqual(query.more_results(), connection._more) | ||
| self.assertEqual(len(entities), 1) | ||
| self.assertEqual(entities[0].key().path(), | ||
| [{'kind': _KIND, 'id': _ID}]) | ||
| @@ -347,6 +352,24 @@ def test_fetch_explicit_limit(self): | ||
| } | ||
| self.assertEqual(connection._called_with, expected_called_with) | ||
| def test_more_results_not_fetched(self): | ||
| _DATASET = 'DATASET' | ||
| _KIND = 'KIND' | ||
| connection = _Connection() | ||
| dataset = _Dataset(_DATASET, connection) | ||
| query = self._makeOne(_KIND, dataset) | ||
| self.assertRaises(RuntimeError, query.more_results) | ||
| def test_more_results_fetched(self): | ||
| _MORE_RESULTS = 2 | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| _DATASET = 'DATASET' | ||
| _KIND = 'KIND' | ||
| connection = _Connection() | ||
| dataset = _Dataset(_DATASET, connection) | ||
| query = self._makeOne(_KIND, dataset) | ||
| query._more_results = _MORE_RESULTS | ||
| self.assertEqual(query.more_results(), _MORE_RESULTS) | ||
| def test_cursor_not_fetched(self): | ||
| _DATASET = 'DATASET' | ||
| _KIND = 'KIND' | ||
| @@ -564,7 +587,7 @@ def connection(self): | ||
| class _Connection(object): | ||
| _called_with = None | ||
| _cursor = '' | ||
| _more = True | ||
| _more = 2 | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| _skipped = 0 | ||
| def __init__(self, *result): | ||
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.