Skip to content

Commit

Permalink
Updating next_page() unit tests to check if skipped_results is set.
Browse files Browse the repository at this point in the history
  • Loading branch information
dhermes committed May 17, 2016
1 parent a4917dd commit a7332dd
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion gcloud/datastore/test_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ def test_ctor_defaults(self):
self.assertTrue(iterator._query is query)
self.assertEqual(iterator._limit, None)
self.assertEqual(iterator._offset, None)
self.assertEqual(iterator._skipped_results, None)

def test_ctor_explicit(self):
client = self._makeClient()
Expand All @@ -400,6 +401,7 @@ def test_next_page_no_cursors_no_more(self):
self._addQueryResults(connection, cursor=b'')
iterator = self._makeOne(query, client)
entities, more_results, cursor = iterator.next_page()
self.assertEqual(iterator._skipped_results, None)

self.assertEqual(cursor, None)
self.assertFalse(more_results)
Expand All @@ -423,13 +425,16 @@ def test_next_page_no_cursors_no_more_w_offset_and_limit(self):
connection = _Connection()
client = self._makeClient(connection)
query = _Query(client, self._KIND, self._PROJECT, self._NAMESPACE)
self._addQueryResults(connection, cursor=b'')
skipped_results = object()
self._addQueryResults(connection, cursor=b'',
skipped_results=skipped_results)
iterator = self._makeOne(query, client, 13, 29)
entities, more_results, cursor = iterator.next_page()

self.assertEqual(cursor, None)
self.assertFalse(more_results)
self.assertFalse(iterator._more_results)
self.assertEqual(iterator._skipped_results, skipped_results)
self.assertEqual(len(entities), 1)
self.assertEqual(entities[0].key.path,
[{'kind': self._KIND, 'id': self._ID}])
Expand Down Expand Up @@ -461,6 +466,7 @@ def test_next_page_w_cursors_w_more(self):
self.assertEqual(cursor, urlsafe_b64encode(self._END))
self.assertTrue(more_results)
self.assertTrue(iterator._more_results)
self.assertEqual(iterator._skipped_results, None)
self.assertEqual(iterator._end_cursor, None)
self.assertEqual(urlsafe_b64decode(iterator._start_cursor), self._END)
self.assertEqual(len(entities), 1)
Expand Down

0 comments on commit a7332dd

Please sign in to comment.