Add tests for limit(None) and fetch_size(...)

This commit is contained in:
Alan Boudreault
2016-03-03 15:35:38 -05:00
parent dabb8d412b
commit a4d329eceb
3 changed files with 24 additions and 2 deletions

View File

@@ -2829,9 +2829,7 @@ class ResponseFuture(object):
.. versionadded:: 2.0.0
"""
log.debug('Pagination: Fetching next page')
if not self._paging_state:
log.debug('Pagination: No more pages to fetch')
raise QueryExhausted()
self._make_query_plan()

View File

@@ -16,6 +16,7 @@ try:
except ImportError:
import unittest # noqa
from cassandra.query import FETCH_SIZE_UNSET
from cassandra.cqlengine.statements import BaseCQLStatement, StatementException
@@ -26,3 +27,14 @@ class BaseStatementTest(unittest.TestCase):
stmt = BaseCQLStatement('table', [])
with self.assertRaises(StatementException):
stmt.add_where_clause('x=5')
def test_fetch_size(self):
""" tests that fetch_size is correctly set """
stmt = BaseCQLStatement('table', None, fetch_size=1000)
self.assertEqual(stmt.fetch_size, 1000)
stmt = BaseCQLStatement('table', None, fetch_size=None)
self.assertEqual(stmt.fetch_size, FETCH_SIZE_UNSET)
stmt = BaseCQLStatement('table', None)
self.assertEqual(stmt.fetch_size, FETCH_SIZE_UNSET)

View File

@@ -96,3 +96,15 @@ class SelectStatementTests(unittest.TestCase):
self.assertIn('ORDER BY x, y', qstr)
self.assertIn('ALLOW FILTERING', qstr)
def test_limit_rendering(self):
ss = SelectStatement('table', None, limit=10)
qstr = six.text_type(ss)
self.assertIn('LIMIT 10', qstr)
ss = SelectStatement('table', None, limit=0)
qstr = six.text_type(ss)
self.assertNotIn('LIMIT', qstr)
ss = SelectStatement('table', None, limit=None)
qstr = six.text_type(ss)
self.assertNotIn('LIMIT', qstr)