http://git-wip-us.apache.org/repos/asf/cassandra-dtest/blob/49b2dda4/paging_test.py ---------------------------------------------------------------------- diff --git a/paging_test.py b/paging_test.py index 24a4739..d41b8f3 100644 --- a/paging_test.py +++ b/paging_test.py @@ -1,5 +1,10 @@ import time import uuid +import pytest +import logging + +from flaky import flaky + from distutils.version import LooseVersion from cassandra import ConsistencyLevel as CL @@ -8,19 +13,21 @@ from cassandra.policies import FallthroughRetryPolicy from cassandra.query import (SimpleStatement, dict_factory, named_tuple_factory, tuple_factory) -from dtest import Tester, debug, run_scenarios, create_ks, supports_v5_protocol +from dtest import Tester, run_scenarios, create_ks from tools.assertions import (assert_all, assert_invalid, assert_length_equal, - assert_one) + assert_one, assert_lists_equal_ignoring_order) from tools.data import rows_to_list from tools.datahelp import create_rows, flatten_into_set, parse_data_into_dicts -from tools.decorators import since from tools.paging import PageAssertionMixin, PageFetcher +since = pytest.mark.since +logger = logging.getLogger(__name__) + class BasePagingTester(Tester): def prepare(self, row_factory=dict_factory): - supports_v5 = supports_v5_protocol(self.cluster.version()) + supports_v5 = self.supports_v5_protocol(self.cluster.version()) protocol_version = 5 if supports_v5 else None cluster = self.cluster cluster.populate(3).start(wait_for_binary_proto=True) @@ -54,8 +61,8 @@ class TestPagingSize(BasePagingTester, PageAssertionMixin): pf = PageFetcher(future) pf.request_all() - self.assertEqual([], pf.all_data()) - self.assertFalse(pf.has_more_pages) + assert [] == pf.all_data() + assert not pf.has_more_pages def test_with_less_results_than_page_size(self): session = self.prepare() @@ -71,7 +78,7 @@ class TestPagingSize(BasePagingTester, PageAssertionMixin): |4 |and more testing| |5 |and more testing| """ - expected_data = create_rows(data, session, 'paging_test', cl=CL.ALL, format_funcs={'id': int, 'value': unicode}) + expected_data = create_rows(data, session, 'paging_test', cl=CL.ALL, format_funcs={'id': int, 'value': str}) future = session.execute_async( SimpleStatement("select * from paging_test", fetch_size=100, consistency_level=CL.ALL) @@ -79,8 +86,8 @@ class TestPagingSize(BasePagingTester, PageAssertionMixin): pf = PageFetcher(future) pf.request_all() - self.assertFalse(pf.has_more_pages) - self.assertEqual(len(expected_data), len(pf.all_data())) + assert not pf.has_more_pages + assert len(expected_data) == len(pf.all_data()) def test_with_more_results_than_page_size(self): session = self.prepare() @@ -100,7 +107,7 @@ class TestPagingSize(BasePagingTester, PageAssertionMixin): |8 |and more testing| |9 |and more testing| """ - expected_data = create_rows(data, session, 'paging_test', cl=CL.ALL, format_funcs={'id': int, 'value': unicode}) + expected_data = create_rows(data, session, 'paging_test', cl=CL.ALL, format_funcs={'id': int, 'value': str}) future = session.execute_async( SimpleStatement("select * from paging_test", fetch_size=5, consistency_level=CL.ALL) @@ -108,11 +115,11 @@ class TestPagingSize(BasePagingTester, PageAssertionMixin): pf = PageFetcher(future).request_all() - self.assertEqual(pf.pagecount(), 2) - self.assertEqual(pf.num_results_all(), [5, 4]) + assert pf.pagecount() == 2 + assert pf.num_results_all() == [5, 4] # make sure expected and actual have same data elements (ignoring order) - self.assertEqualIgnoreOrder(pf.all_data(), expected_data) + assert_lists_equal_ignoring_order(expected_data, pf.all_data(), sort_key="id") def test_with_equal_results_to_page_size(self): session = self.prepare() @@ -128,7 +135,7 @@ class TestPagingSize(BasePagingTester, PageAssertionMixin): |4 |and more testing| |5 |and more testing| """ - expected_data = create_rows(data, session, 'paging_test', cl=CL.ALL, format_funcs={'id': int, 'value': unicode}) + expected_data = create_rows(data, session, 'paging_test', cl=CL.ALL, format_funcs={'id': int, 'value': str}) future = session.execute_async( SimpleStatement("select * from paging_test", fetch_size=5, consistency_level=CL.ALL) @@ -136,11 +143,11 @@ class TestPagingSize(BasePagingTester, PageAssertionMixin): pf = PageFetcher(future).request_all() - self.assertEqual(pf.num_results_all(), [5]) - self.assertEqual(pf.pagecount(), 1) + assert pf.num_results_all() == [5] + assert pf.pagecount() == 1 # make sure expected and actual have same data elements (ignoring order) - self.assertEqualIgnoreOrder(pf.all_data(), expected_data) + assert_lists_equal_ignoring_order(expected_data, pf.all_data(), sort_key="id") def test_undefined_page_size_default(self): """ @@ -158,7 +165,7 @@ class TestPagingSize(BasePagingTester, PageAssertionMixin): +--------+--------+ *5001| [uuid] |testing | """ - expected_data = create_rows(data, session, 'paging_test', cl=CL.ALL, format_funcs={'id': random_txt, 'value': unicode}) + expected_data = create_rows(data, session, 'paging_test', cl=CL.ALL, format_funcs={'id': random_txt, 'value': str}) future = session.execute_async( SimpleStatement("select * from paging_test", consistency_level=CL.ALL) @@ -166,10 +173,10 @@ class TestPagingSize(BasePagingTester, PageAssertionMixin): pf = PageFetcher(future).request_all() - self.assertEqual(pf.num_results_all(), [5000, 1]) + assert pf.num_results_all(), [5000, 1] # make sure expected and actual have same data elements (ignoring order) - self.assertEqualIgnoreOrder(pf.all_data(), expected_data) + assert_lists_equal_ignoring_order(expected_data, pf.all_data(), sort_key="id") @since('2.0') @@ -209,7 +216,7 @@ class TestPagingWithModifiers(BasePagingTester, PageAssertionMixin): |1 |j | """ - expected_data = create_rows(data, session, 'paging_test', cl=CL.ALL, format_funcs={'id': int, 'value': unicode}) + expected_data = create_rows(data, session, 'paging_test', cl=CL.ALL, format_funcs={'id': int, 'value': str}) future = session.execute_async( SimpleStatement("select * from paging_test where id = 1 order by value asc", fetch_size=5, consistency_level=CL.ALL) @@ -217,14 +224,14 @@ class TestPagingWithModifiers(BasePagingTester, PageAssertionMixin): pf = PageFetcher(future).request_all() - self.assertEqual(pf.pagecount(), 2) - self.assertEqual(pf.num_results_all(), [5, 5]) + assert pf.pagecount() == 2 + assert pf.num_results_all() == [5, 5] # these should be equal (in the same order) - self.assertEqual(pf.all_data(), expected_data) + assert pf.all_data() == expected_data # make sure we don't allow paging over multiple partitions with order because that's weird - with self.assertRaisesRegexp(InvalidRequest, 'Cannot page queries with both ORDER BY and a IN restriction on the partition key'): + with pytest.raises(InvalidRequest, match='Cannot page queries with both ORDER BY and a IN restriction on the partition key'): stmt = SimpleStatement("select * from paging_test where id in (1,2) order by value asc", consistency_level=CL.ALL) session.execute(stmt) @@ -259,7 +266,7 @@ class TestPagingWithModifiers(BasePagingTester, PageAssertionMixin): |1 |j |j | """ - expected_data = create_rows(data, session, 'paging_test', cl=CL.ALL, format_funcs={'id': int, 'value': unicode, 'value2': unicode}) + expected_data = create_rows(data, session, 'paging_test', cl=CL.ALL, format_funcs={'id': int, 'value': str, 'value2': str}) future = session.execute_async( SimpleStatement("select * from paging_test where id = 1 order by value asc", fetch_size=3, consistency_level=CL.ALL) @@ -267,11 +274,11 @@ class TestPagingWithModifiers(BasePagingTester, PageAssertionMixin): pf = PageFetcher(future).request_all() - self.assertEqual(pf.pagecount(), 4) - self.assertEqual(pf.num_results_all(), [3, 3, 3, 1]) + assert pf.pagecount() == 4 + assert pf.num_results_all(), [3, 3, 3, 1] # these should be equal (in the same order) - self.assertEqual(pf.all_data(), expected_data) + assert pf.all_data() == expected_data # drop the ORDER BY future = session.execute_async( @@ -280,11 +287,11 @@ class TestPagingWithModifiers(BasePagingTester, PageAssertionMixin): pf = PageFetcher(future).request_all() - self.assertEqual(pf.pagecount(), 4) - self.assertEqual(pf.num_results_all(), [3, 3, 3, 1]) + assert pf.pagecount() == 4 + assert pf.num_results_all(), [3, 3, 3, 1] # these should be equal (in the same order) - self.assertEqual(pf.all_data(), list(reversed(expected_data))) + assert pf.all_data() == list(reversed(expected_data)) def test_with_limit(self): session = self.prepare() @@ -292,7 +299,7 @@ class TestPagingWithModifiers(BasePagingTester, PageAssertionMixin): session.execute("CREATE TABLE paging_test ( id int, value text, PRIMARY KEY (id, value) )") def random_txt(text): - return unicode(uuid.uuid4()) + return str(uuid.uuid4()) data = """ | id | value | @@ -361,8 +368,8 @@ class TestPagingWithModifiers(BasePagingTester, PageAssertionMixin): self.fail("Invalid scenario configuration. Scenario is: {}".format(scenario)) pf = PageFetcher(future).request_all() - self.assertEqual(pf.num_results_all(), scenario['expect_pgsizes']) - self.assertEqual(pf.pagecount(), scenario['expect_pgcount']) + assert pf.num_results_all() == scenario['expect_pgsizes'] + assert pf.pagecount() == scenario['expect_pgcount'] # make sure all the data retrieved is a subset of input data self.assertIsSubsetOf(pf.all_data(), expected_data) @@ -387,7 +394,7 @@ class TestPagingWithModifiers(BasePagingTester, PageAssertionMixin): |8 |and more testing| |9 |and more testing| """ - create_rows(data, session, 'paging_test', cl=CL.ALL, format_funcs={'id': int, 'value': unicode}) + create_rows(data, session, 'paging_test', cl=CL.ALL, format_funcs={'id': int, 'value': str}) future = session.execute_async( SimpleStatement("select * from paging_test where value = 'and more testing' ALLOW FILTERING", fetch_size=4, consistency_level=CL.ALL) @@ -395,26 +402,24 @@ class TestPagingWithModifiers(BasePagingTester, PageAssertionMixin): pf = PageFetcher(future).request_all() - self.assertEqual(pf.pagecount(), 2) - self.assertEqual(pf.num_results_all(), [4, 3]) + assert pf.pagecount() == 2 + assert pf.num_results_all() == [4, 3] # make sure the allow filtering query matches the expected results (ignoring order) - self.assertEqualIgnoreOrder( - pf.all_data(), - parse_data_into_dicts( - """ - |id|value | - +--+----------------+ - |2 |and more testing| - |3 |and more testing| - |4 |and more testing| - |5 |and more testing| - |7 |and more testing| - |8 |and more testing| - |9 |and more testing| - """, format_funcs={'id': int, 'value': unicode} - ) + expected_data = parse_data_into_dicts( + """ + |id|value | + +--+----------------+ + |2 |and more testing| + |3 |and more testing| + |4 |and more testing| + |5 |and more testing| + |7 |and more testing| + |8 |and more testing| + |9 |and more testing| + """, format_funcs={'id': int, 'value': str} ) + assert_lists_equal_ignoring_order(expected_data, pf.all_data(), sort_key="value") @since('2.0') @@ -426,7 +431,7 @@ class TestPagingData(BasePagingTester, PageAssertionMixin): session.execute("CREATE TABLE paging_test ( id int, value text, PRIMARY KEY (id, value) )") def random_txt(text): - return unicode(uuid.uuid4()) + return str(uuid.uuid4()) data = """ | id | value | @@ -441,10 +446,9 @@ class TestPagingData(BasePagingTester, PageAssertionMixin): pf = PageFetcher(future).request_all() - self.assertEqual(pf.pagecount(), 4) - self.assertEqual(pf.num_results_all(), [3000, 3000, 3000, 1000]) - - self.assertEqualIgnoreOrder(pf.all_data(), expected_data) + assert pf.pagecount() == 4 + assert pf.num_results_all(), [3000, 3000, 3000, 1000] + assert_lists_equal_ignoring_order(expected_data, pf.all_data(), sort_key="value") def test_paging_across_multi_wide_rows(self): session = self.prepare() @@ -452,7 +456,7 @@ class TestPagingData(BasePagingTester, PageAssertionMixin): session.execute("CREATE TABLE paging_test ( id int, value text, PRIMARY KEY (id, value) )") def random_txt(text): - return unicode(uuid.uuid4()) + return str(uuid.uuid4()) data = """ | id | value | @@ -468,10 +472,9 @@ class TestPagingData(BasePagingTester, PageAssertionMixin): pf = PageFetcher(future).request_all() - self.assertEqual(pf.pagecount(), 4) - self.assertEqual(pf.num_results_all(), [3000, 3000, 3000, 1000]) - - self.assertEqualIgnoreOrder(pf.all_data(), expected_data) + assert pf.pagecount() == 4 + assert pf.num_results_all(), [3000, 3000, 3000, 1000] + assert_lists_equal_ignoring_order(expected_data, pf.all_data(), sort_key="value") def test_paging_using_secondary_indexes(self): session = self.prepare() @@ -480,7 +483,7 @@ class TestPagingData(BasePagingTester, PageAssertionMixin): session.execute("CREATE INDEX ON paging_test(mybool)") def random_txt(text): - return unicode(uuid.uuid4()) + return str(uuid.uuid4()) def bool_from_str_int(text): return bool(int(text)) @@ -505,11 +508,11 @@ class TestPagingData(BasePagingTester, PageAssertionMixin): pf = PageFetcher(future).request_all() # the query only searched for True rows, so let's pare down the expectations for comparison - expected_data = filter(lambda x: x.get('mybool') is True, all_data) + expected_data = [x for x in all_data if x.get('mybool') is True] - self.assertEqual(pf.pagecount(), 2) - self.assertEqual(pf.num_results_all(), [400, 200]) - self.assertEqualIgnoreOrder(expected_data, pf.all_data()) + assert pf.pagecount() == 2 + assert pf.num_results_all() == [400, 200] + assert_lists_equal_ignoring_order(expected_data, pf.all_data(), sort_key="sometext") def test_paging_with_in_orderby_and_two_partition_keys(self): session = self.prepare() @@ -520,11 +523,10 @@ class TestPagingData(BasePagingTester, PageAssertionMixin): assert_invalid(session, "select * from paging_test where col_2 IN (1, 2) and col_1=1 order by col_3 desc;", expected=InvalidRequest) @since('3.10') - def group_by_paging_test(self): + def test_group_by_paging(self): """ @jira_ticket CASSANDRA-10707 """ - session = self.prepare(row_factory=tuple_factory) create_ks(session, 'test_paging_with_group_by', 2) session.execute("CREATE TABLE test (a int, b int, c int, d int, e int, primary key (a, b, c, d))") @@ -548,333 +550,332 @@ class TestPagingData(BasePagingTester, PageAssertionMixin): # Range queries res = rows_to_list(session.execute("SELECT a, b, e, count(b), max(e) FROM test GROUP BY a")) - self.assertEqual(res, [[1, 2, 6, 4L, 24], [2, 2, 6, 2L, 12], [4, 8, 24, 1L, 24]]) + assert res == [[1, 2, 6, 4, 24], [2, 2, 6, 2, 12], [4, 8, 24, 1, 24]] res = rows_to_list(session.execute("SELECT a, b, e, count(b), max(e) FROM test GROUP BY a, b")) - self.assertEqual(res, [[1, 2, 6, 2L, 12], - [1, 4, 12, 2L, 24], - [2, 2, 6, 1L, 6], - [2, 4, 12, 1L, 12], - [4, 8, 24, 1L, 24]]) + assert res == [[1, 2, 6, 2, 12], + [1, 4, 12, 2, 24], + [2, 2, 6, 1, 6], + [2, 4, 12, 1, 12], + [4, 8, 24, 1, 24]] res = rows_to_list(session.execute("SELECT a, b, e, count(b), max(e) FROM test")) - self.assertEqual(res, [[1, 2, 6, 7L, 24]]) + assert res == [[1, 2, 6, 7, 24]] res = rows_to_list( session.execute("SELECT a, b, e, count(b), max(e) FROM test WHERE b = 2 GROUP BY a, b ALLOW FILTERING")) - self.assertEqual(res, [[1, 2, 6, 2L, 12], - [2, 2, 6, 1L, 6]]) + assert res == [[1, 2, 6, 2, 12], + [2, 2, 6, 1, 6]] assert_invalid(session, "SELECT a, b, e, count(b), max(e) FROM test WHERE b = 2 GROUP BY a, b;", expected=InvalidRequest) res = rows_to_list( session.execute("SELECT a, b, e, count(b), max(e) FROM test WHERE b = 2 ALLOW FILTERING")) - self.assertEqual(res, [[1, 2, 6, 3L, 12]]) + assert res == [[1, 2, 6, 3, 12]] assert_invalid(session, "SELECT a, b, e, count(b), max(e) FROM test WHERE b = 2", expected=InvalidRequest) # Range queries without aggregates res = rows_to_list(session.execute("SELECT a, b, c, d FROM test GROUP BY a, b, c")) - self.assertEqual(res, [[1, 2, 1, 3], - [1, 2, 2, 6], - [1, 4, 2, 6], - [2, 2, 3, 3], - [2, 4, 3, 6], - [4, 8, 2, 12]]) + assert res == [[1, 2, 1, 3], + [1, 2, 2, 6], + [1, 4, 2, 6], + [2, 2, 3, 3], + [2, 4, 3, 6], + [4, 8, 2, 12]] res = rows_to_list(session.execute("SELECT a, b, c, d FROM test GROUP BY a, b")) - self.assertEqual(res, [[1, 2, 1, 3], - [1, 4, 2, 6], - [2, 2, 3, 3], - [2, 4, 3, 6], - [4, 8, 2, 12]]) + assert res == [[1, 2, 1, 3], + [1, 4, 2, 6], + [2, 2, 3, 3], + [2, 4, 3, 6], + [4, 8, 2, 12]] # Range query with LIMIT res = rows_to_list(session.execute("SELECT a, b, e, count(b), max(e) FROM test GROUP BY a, b LIMIT 2")) - self.assertEqual(res, [[1, 2, 6, 2L, 12], - [1, 4, 12, 2L, 24]]) + assert res == [[1, 2, 6, 2, 12], + [1, 4, 12, 2, 24]] res = rows_to_list(session.execute("SELECT a, b, e, count(b), max(e) FROM test LIMIT 2")) - self.assertEqual(res, [[1, 2, 6, 7L, 24]]) + assert res == [[1, 2, 6, 7, 24]] # Range queries without aggregates and with LIMIT res = rows_to_list(session.execute("SELECT a, b, c, d FROM test GROUP BY a, b, c LIMIT 3")) - self.assertEqual(res, [[1, 2, 1, 3], - [1, 2, 2, 6], - [1, 4, 2, 6]]) + assert res == [[1, 2, 1, 3], + [1, 2, 2, 6], + [1, 4, 2, 6]] res = rows_to_list(session.execute("SELECT a, b, c, d FROM test GROUP BY a, b LIMIT 3")) - self.assertEqual(res, [[1, 2, 1, 3], - [1, 4, 2, 6], - [2, 2, 3, 3]]) + assert res == [[1, 2, 1, 3], + [1, 4, 2, 6], + [2, 2, 3, 3]] # Range query with PER PARTITION LIMIT res = rows_to_list(session.execute("SELECT a, b, e, count(b), max(e) FROM test GROUP BY a, b PER PARTITION LIMIT 2")) - self.assertEqual(res, [[1, 2, 6, 2L, 12], - [1, 4, 12, 2L, 24], - [2, 2, 6, 1L, 6], - [2, 4, 12, 1L, 12], - [4, 8, 24, 1L, 24]]) + assert res == [[1, 2, 6, 2, 12], + [1, 4, 12, 2, 24], + [2, 2, 6, 1, 6], + [2, 4, 12, 1, 12], + [4, 8, 24, 1, 24]] res = rows_to_list(session.execute("SELECT a, b, e, count(b), max(e) FROM test GROUP BY a, b PER PARTITION LIMIT 1")) - self.assertEqual(res, [[1, 2, 6, 2L, 12], - [2, 2, 6, 1L, 6], - [4, 8, 24, 1L, 24]]) + assert res == [[1, 2, 6, 2, 12], + [2, 2, 6, 1, 6], + [4, 8, 24, 1, 24]] # Range queries with PER PARTITION LIMIT and LIMIT res = rows_to_list(session.execute("SELECT a, b, e, count(b), max(e) FROM test GROUP BY a, b PER PARTITION LIMIT 2 LIMIT 3")) - self.assertEqual(res, [[1, 2, 6, 2L, 12], - [1, 4, 12, 2L, 24], - [2, 2, 6, 1L, 6]]) + assert res == [[1, 2, 6, 2, 12], + [1, 4, 12, 2, 24], + [2, 2, 6, 1, 6]] res = rows_to_list(session.execute("SELECT a, b, e, count(b), max(e) FROM test GROUP BY a, b PER PARTITION LIMIT 2 LIMIT 5")) - self.assertEqual(res, [[1, 2, 6, 2L, 12], - [1, 4, 12, 2L, 24], - [2, 2, 6, 1L, 6], - [2, 4, 12, 1L, 12], - [4, 8, 24, 1L, 24]]) + assert res == [[1, 2, 6, 2, 12], + [1, 4, 12, 2, 24], + [2, 2, 6, 1, 6], + [2, 4, 12, 1, 12], + [4, 8, 24, 1, 24]] res = rows_to_list(session.execute("SELECT a, b, e, count(b), max(e) FROM test GROUP BY a, b PER PARTITION LIMIT 2 LIMIT 10")) - self.assertEqual(res, [[1, 2, 6, 2L, 12], - [1, 4, 12, 2L, 24], - [2, 2, 6, 1L, 6], - [2, 4, 12, 1L, 12], - [4, 8, 24, 1L, 24]]) + assert res == [[1, 2, 6, 2, 12], + [1, 4, 12, 2, 24], + [2, 2, 6, 1, 6], + [2, 4, 12, 1, 12], + [4, 8, 24, 1, 24]] # Range queries without aggregates and with PER PARTITION LIMIT res = rows_to_list(session.execute("SELECT a, b, c, d FROM test GROUP BY a, b, c PER PARTITION LIMIT 2")) - self.assertEqual(res, [[1, 2, 1, 3], - [1, 2, 2, 6], - [2, 2, 3, 3], - [2, 4, 3, 6], - [4, 8, 2, 12]]) + assert res == [[1, 2, 1, 3], + [1, 2, 2, 6], + [2, 2, 3, 3], + [2, 4, 3, 6], + [4, 8, 2, 12]] res = rows_to_list(session.execute("SELECT a, b, c, d FROM test GROUP BY a, b PER PARTITION LIMIT 1")) - self.assertEqual(res, [[1, 2, 1, 3], - [2, 2, 3, 3], - [4, 8, 2, 12]]) + assert res == [[1, 2, 1, 3], + [2, 2, 3, 3], + [4, 8, 2, 12]] # Range query with DISTINCT res = rows_to_list(session.execute("SELECT DISTINCT a, count(a)FROM test GROUP BY a")) - self.assertEqual(res, [[1, 1L], - [2, 1L], - [4, 1L]]) + assert res == [[1, 1], + [2, 1], + [4, 1]] res = rows_to_list(session.execute("SELECT DISTINCT a, count(a)FROM test")) - self.assertEqual(res, [[1, 3L]]) + assert res == [[1, 3]] # Range query with DISTINCT and LIMIT res = rows_to_list(session.execute("SELECT DISTINCT a, count(a)FROM test GROUP BY a LIMIT 2")) - self.assertEqual(res, [[1, 1L], - [2, 1L]]) + assert res == [[1, 1], + [2, 1]] res = rows_to_list(session.execute("SELECT DISTINCT a, count(a)FROM test LIMIT 2")) - self.assertEqual(res, [[1, 3L]]) + assert res == [[1, 3]] # Single partition queries res = rows_to_list( session.execute("SELECT a, b, e, count(b), max(e) FROM test WHERE a = 1 GROUP BY a, b, c")) - self.assertEqual(res, [[1, 2, 6, 1L, 6], - [1, 2, 12, 1L, 12], - [1, 4, 12, 2L, 24]]) + assert res == [[1, 2, 6, 1, 6], + [1, 2, 12, 1, 12], + [1, 4, 12, 2, 24]] res = rows_to_list(session.execute("SELECT a, b, e, count(b), max(e) FROM test WHERE a = 1")) - self.assertEqual(res, [[1, 2, 6, 4L, 24]]) + assert res == [[1, 2, 6, 4, 24]] res = rows_to_list( session.execute("SELECT a, b, e, count(b), max(e) FROM test WHERE a = 1 AND b = 2 GROUP BY a, b, c")) - self.assertEqual(res, [[1, 2, 6, 1L, 6], - [1, 2, 12, 1L, 12]]) + assert res == [[1, 2, 6, 1, 6], + [1, 2, 12, 1, 12]] res = rows_to_list(session.execute("SELECT a, b, e, count(b), max(e) FROM test WHERE a = 1 AND b = 2")) - self.assertEqual(res, [[1, 2, 6, 2L, 12]]) + assert res == [[1, 2, 6, 2, 12]] # Single partition queries without aggregates res = rows_to_list(session.execute("SELECT a, b, c, d FROM test WHERE a = 1 GROUP BY a, b")) - self.assertEqual(res, [[1, 2, 1, 3], - [1, 4, 2, 6]]) + assert res == [[1, 2, 1, 3], + [1, 4, 2, 6]] res = rows_to_list(session.execute("SELECT a, b, c, d FROM test WHERE a = 1 GROUP BY a, b, c")) - self.assertEqual(res, [[1, 2, 1, 3], - [1, 2, 2, 6], - [1, 4, 2, 6]]) + assert res == [[1, 2, 1, 3], + [1, 2, 2, 6], + [1, 4, 2, 6]] # Single partition query with DISTINCT res = rows_to_list(session.execute("SELECT DISTINCT a, count(a)FROM test WHERE a = 1 GROUP BY a")) - self.assertEqual(res, [[1, 1L]]) + assert res == [[1, 1]] res = rows_to_list(session.execute("SELECT DISTINCT a, count(a)FROM test WHERE a = 1 GROUP BY a")) - self.assertEqual(res, [[1, 1L]]) + assert res == [[1, 1]] # Single partition queries with LIMIT res = rows_to_list( session.execute("SELECT a, b, e, count(b), max(e) FROM test WHERE a = 1 GROUP BY a, b, c LIMIT 10")) - self.assertEqual(res, [[1, 2, 6, 1L, 6], - [1, 2, 12, 1L, 12], - [1, 4, 12, 2L, 24]]) + assert res == [[1, 2, 6, 1, 6], + [1, 2, 12, 1, 12], + [1, 4, 12, 2, 24]] res = rows_to_list( session.execute("SELECT a, b, e, count(b), max(e) FROM test WHERE a = 1 GROUP BY a, b, c LIMIT 2")) - self.assertEqual(res, [[1, 2, 6, 1L, 6], - [1, 2, 12, 1L, 12]]) + assert res == [[1, 2, 6, 1, 6], + [1, 2, 12, 1, 12]] res = rows_to_list(session.execute("SELECT a, b, e, count(b), max(e) FROM test WHERE a = 1 LIMIT 2")) - self.assertEqual(res, [[1, 2, 6, 4L, 24]]) + assert res == [[1, 2, 6, 4, 24]] res = rows_to_list( session.execute("SELECT count(b), max(e) FROM test WHERE a = 1 GROUP BY a, b, c LIMIT 1")) - self.assertEqual(res, [[1L, 6]]) + assert res == [[1, 6]] # Single partition queries with PER PARTITION LIMIT res = rows_to_list( session.execute("SELECT a, b, e, count(b), max(e) FROM test WHERE a = 1 GROUP BY a, b, c PER PARTITION LIMIT 2")) - self.assertEqual(res, [[1, 2, 6, 1L, 6], - [1, 2, 12, 1L, 12]]) + assert res == [[1, 2, 6, 1, 6], + [1, 2, 12, 1, 12]] res = rows_to_list( session.execute("SELECT a, b, e, count(b), max(e) FROM test WHERE a = 1 GROUP BY a, b, c PER PARTITION LIMIT 3")) - self.assertEqual(res, [[1, 2, 6, 1L, 6], - [1, 2, 12, 1L, 12], - [1, 4, 12, 2L, 24]]) + assert res == [[1, 2, 6, 1, 6], + [1, 2, 12, 1, 12], + [1, 4, 12, 2, 24]] res = rows_to_list( session.execute("SELECT a, b, e, count(b), max(e) FROM test WHERE a = 1 GROUP BY a, b, c PER PARTITION LIMIT 3")) - self.assertEqual(res, [[1, 2, 6, 1L, 6], - [1, 2, 12, 1L, 12], - [1, 4, 12, 2L, 24]]) + assert res == [[1, 2, 6, 1, 6], + [1, 2, 12, 1, 12], + [1, 4, 12, 2, 24]] # Single partition queries without aggregates and with LIMIT res = rows_to_list(session.execute("SELECT a, b, c, d FROM test WHERE a = 1 GROUP BY a, b LIMIT 2")) - self.assertEqual(res, [[1, 2, 1, 3], - [1, 4, 2, 6]]) + assert res == [[1, 2, 1, 3], + [1, 4, 2, 6]] res = rows_to_list(session.execute("SELECT a, b, c, d FROM test WHERE a = 1 GROUP BY a, b LIMIT 1")) - self.assertEqual(res, [[1, 2, 1, 3]]) + assert res == [[1, 2, 1, 3]] res = rows_to_list(session.execute("SELECT a, b, c, d FROM test WHERE a = 1 GROUP BY a, b, c LIMIT 2")) - self.assertEqual(res, [[1, 2, 1, 3], - [1, 2, 2, 6]]) + assert res == [[1, 2, 1, 3], + [1, 2, 2, 6]] # Single partition queries with ORDER BY res = rows_to_list(session.execute( "SELECT a, b, e, count(b), max(e) FROM test WHERE a = 1 GROUP BY a, b, c ORDER BY b DESC, c DESC")) - self.assertEqual(res, [[1, 4, 24, 2L, 24], - [1, 2, 12, 1L, 12], - [1, 2, 6, 1L, 6]]) + assert res == [[1, 4, 24, 2, 24], + [1, 2, 12, 1, 12], + [1, 2, 6, 1, 6]] res = rows_to_list( session.execute("SELECT a, b, e, count(b), max(e) FROM test WHERE a = 1 ORDER BY b DESC, c DESC")) - self.assertEqual(res, [[1, 4, 24, 4L, 24]]) + assert res == [[1, 4, 24, 4, 24]] # Single partition queries with ORDER BY and LIMIT res = rows_to_list(session.execute( "SELECT a, b, e, count(b), max(e) FROM test WHERE a = 1 GROUP BY a, b, c ORDER BY b DESC, c DESC LIMIT 2")) - self.assertEqual(res, [[1, 4, 24, 2L, 24], - [1, 2, 12, 1L, 12]]) + assert res == [[1, 4, 24, 2, 24], + [1, 2, 12, 1, 12]] res = rows_to_list(session.execute( "SELECT a, b, e, count(b), max(e) FROM test WHERE a = 1 ORDER BY b DESC, c DESC LIMIT 2")) - self.assertEqual(res, [[1, 4, 24, 4L, 24]]) + assert res == [[1, 4, 24, 4, 24]] # Multi-partitions queries res = rows_to_list( session.execute("SELECT a, b, e, count(b), max(e) FROM test WHERE a IN (1, 2, 4) GROUP BY a, b, c")) - self.assertEqual(res, [[1, 2, 6, 1L, 6], - [1, 2, 12, 1L, 12], - [1, 4, 12, 2L, 24], - [2, 2, 6, 1L, 6], - [2, 4, 12, 1L, 12], - [4, 8, 24, 1L, 24]]) + assert res == [[1, 2, 6, 1, 6], + [1, 2, 12, 1, 12], + [1, 4, 12, 2, 24], + [2, 2, 6, 1, 6], + [2, 4, 12, 1, 12], + [4, 8, 24, 1, 24]] res = rows_to_list(session.execute("SELECT a, b, e, count(b), max(e) FROM test WHERE a IN (1, 2, 4)")) - self.assertEqual(res, [[1, 2, 6, 7L, 24]]) + assert res == [[1, 2, 6, 7, 24]] res = rows_to_list(session.execute( "SELECT a, b, e, count(b), max(e) FROM test WHERE a IN (1, 2, 4) AND b = 2 GROUP BY a, b, c")) - self.assertEqual(res, [[1, 2, 6, 1L, 6], - [1, 2, 12, 1L, 12], - [2, 2, 6, 1L, 6]]) + assert res == [[1, 2, 6, 1, 6], + [1, 2, 12, 1, 12], + [2, 2, 6, 1, 6]] res = rows_to_list( session.execute("SELECT a, b, e, count(b), max(e) FROM test WHERE a IN (1, 2, 4) AND b = 2")) - self.assertEqual(res, [[1, 2, 6, 3L, 12]]) + assert res == [[1, 2, 6, 3, 12]] # Multi-partitions queries without aggregates res = rows_to_list(session.execute("SELECT a, b, c, d FROM test WHERE a IN (1, 2, 4) GROUP BY a, b")) - self.assertEqual(res, [[1, 2, 1, 3], - [1, 4, 2, 6], - [2, 2, 3, 3], - [2, 4, 3, 6], - [4, 8, 2, 12]]) + assert res == [[1, 2, 1, 3], + [1, 4, 2, 6], + [2, 2, 3, 3], + [2, 4, 3, 6], + [4, 8, 2, 12]] res = rows_to_list(session.execute("SELECT a, b, c, d FROM test WHERE a IN (1, 2, 4) GROUP BY a, b, c")) - self.assertEqual(res, [[1, 2, 1, 3], - [1, 2, 2, 6], - [1, 4, 2, 6], - [2, 2, 3, 3], - [2, 4, 3, 6], - [4, 8, 2, 12]]) + assert res == [[1, 2, 1, 3], + [1, 2, 2, 6], + [1, 4, 2, 6], + [2, 2, 3, 3], + [2, 4, 3, 6], + [4, 8, 2, 12]] # Multi-partitions queries with DISTINCT res = rows_to_list(session.execute("SELECT DISTINCT a, count(a)FROM test WHERE a IN (1, 2, 4) GROUP BY a")) - self.assertEqual(res, [[1, 1L], - [2, 1L], - [4, 1L]]) + assert res == [[1, 1], + [2, 1], + [4, 1]] res = rows_to_list(session.execute("SELECT DISTINCT a, count(a)FROM test WHERE a IN (1, 2, 4)")) - self.assertEqual(res, [[1, 3L]]) + assert res == [[1, 3]] # Multi-partitions query with DISTINCT and LIMIT res = rows_to_list( session.execute("SELECT DISTINCT a, count(a)FROM test WHERE a IN (1, 2, 4) GROUP BY a LIMIT 2")) - self.assertEqual(res, [[1, 1L], - [2, 1L]]) + assert res == [[1, 1], + [2, 1]] res = rows_to_list(session.execute("SELECT DISTINCT a, count(a)FROM test WHERE a IN (1, 2, 4) LIMIT 2")) - self.assertEqual(res, [[1, 3L]]) + assert res == [[1, 3]] # Multi-partitions queries without aggregates and with PER PARTITION LIMIT res = rows_to_list(session.execute("SELECT a, b, c, d FROM test WHERE a IN (1, 2, 4) GROUP BY a, b PER PARTITION LIMIT 1")) - self.assertEqual(res, [[1, 2, 1, 3], - [2, 2, 3, 3], - [4, 8, 2, 12]]) + assert res == [[1, 2, 1, 3], + [2, 2, 3, 3], + [4, 8, 2, 12]] res = rows_to_list(session.execute("SELECT a, b, c, d FROM test WHERE a IN (1, 2, 4) GROUP BY a, b PER PARTITION LIMIT 2")) - self.assertEqual(res, [[1, 2, 1, 3], - [1, 4, 2, 6], - [2, 2, 3, 3], - [2, 4, 3, 6], - [4, 8, 2, 12]]) + assert res == [[1, 2, 1, 3], + [1, 4, 2, 6], + [2, 2, 3, 3], + [2, 4, 3, 6], + [4, 8, 2, 12]] res = rows_to_list(session.execute("SELECT a, b, c, d FROM test WHERE a IN (1, 2, 4) GROUP BY a, b PER PARTITION LIMIT 3")) - self.assertEqual(res, [[1, 2, 1, 3], - [1, 4, 2, 6], - [2, 2, 3, 3], - [2, 4, 3, 6], - [4, 8, 2, 12]]) + assert res == [[1, 2, 1, 3], + [1, 4, 2, 6], + [2, 2, 3, 3], + [2, 4, 3, 6], + [4, 8, 2, 12]] # Multi-partitions queries without aggregates, with PER PARTITION LIMIT and with LIMIT res = rows_to_list(session.execute("SELECT a, b, c, d FROM test WHERE a IN (1, 2, 4) GROUP BY a, b PER PARTITION LIMIT 1 LIMIT 2")) - self.assertEqual(res, [[1, 2, 1, 3], - [2, 2, 3, 3]]) + assert res == [[1, 2, 1, 3], + [2, 2, 3, 3]] res = rows_to_list(session.execute("SELECT a, b, c, d FROM test WHERE a IN (1, 2, 4) GROUP BY a, b PER PARTITION LIMIT 3 LIMIT 2")) - self.assertEqual(res, [[1, 2, 1, 3], - [1, 4, 2, 6]]) + assert res == [[1, 2, 1, 3], + [1, 4, 2, 6]] @since('3.10') - def group_by_with_range_name_query_paging_test(self): + def test_group_by_with_range_name_query_paging(self): """ @jira_ticket CASSANDRA-10707 """ - session = self.prepare(row_factory=tuple_factory) create_ks(session, 'group_by_with_range_name_query_paging_test', 2) session.execute("CREATE TABLE test (a int, b int, c int, d int, primary key (a, b, c))") - for i in xrange(1, 5): - for j in xrange(1, 5): - for k in xrange(1, 5): + for i in range(1, 5): + for j in range(1, 5): + for k in range(1, 5): session.execute("INSERT INTO test (a, b, c, d) VALUES ({}, {}, {}, {})".format(i, j, k, i + j)) # Makes sure that we have some tombstones @@ -885,62 +886,62 @@ class TestPagingData(BasePagingTester, PageAssertionMixin): # Range queries res = rows_to_list(session.execute("SELECT a, b, d, count(b), max(d) FROM test WHERE b = 1 and c IN (1, 2) GROUP BY a ALLOW FILTERING")) - self.assertEqual(res, [[1, 1, 2, 2L, 2], - [2, 1, 3, 2L, 3], - [4, 1, 5, 2L, 5]]) + assert res == [[1, 1, 2, 2, 2], + [2, 1, 3, 2, 3], + [4, 1, 5, 2, 5]] res = rows_to_list(session.execute("SELECT a, b, d, count(b), max(d) FROM test WHERE b = 1 and c IN (1, 2) GROUP BY a, b ALLOW FILTERING")) - self.assertEqual(res, [[1, 1, 2, 2L, 2], - [2, 1, 3, 2L, 3], - [4, 1, 5, 2L, 5]]) + assert res == [[1, 1, 2, 2, 2], + [2, 1, 3, 2, 3], + [4, 1, 5, 2, 5]] res = rows_to_list(session.execute("SELECT a, b, d, count(b), max(d) FROM test WHERE b IN (1, 2) and c IN (1, 2) GROUP BY a, b ALLOW FILTERING")) - self.assertEqual(res, [[1, 1, 2, 2L, 2], - [1, 2, 3, 2L, 3], - [2, 1, 3, 2L, 3], - [2, 2, 4, 2L, 4], - [4, 1, 5, 2L, 5], - [4, 2, 6, 2L, 6]]) + assert res == [[1, 1, 2, 2, 2], + [1, 2, 3, 2, 3], + [2, 1, 3, 2, 3], + [2, 2, 4, 2, 4], + [4, 1, 5, 2, 5], + [4, 2, 6, 2, 6]] # Range queries with LIMIT res = rows_to_list(session.execute("SELECT a, b, d, count(b), max(d) FROM test WHERE b = 1 and c IN (1, 2) GROUP BY a LIMIT 5 ALLOW FILTERING")) - self.assertEqual(res, [[1, 1, 2, 2L, 2], - [2, 1, 3, 2L, 3], - [4, 1, 5, 2L, 5]]) + assert res == [[1, 1, 2, 2, 2], + [2, 1, 3, 2, 3], + [4, 1, 5, 2, 5]] res = rows_to_list(session.execute("SELECT a, b, d, count(b), max(d) FROM test WHERE b = 1 and c IN (1, 2) GROUP BY a, b LIMIT 3 ALLOW FILTERING")) - self.assertEqual(res, [[1, 1, 2, 2L, 2], - [2, 1, 3, 2L, 3], - [4, 1, 5, 2L, 5]]) + assert res == [[1, 1, 2, 2, 2], + [2, 1, 3, 2, 3], + [4, 1, 5, 2, 5]] res = rows_to_list(session.execute("SELECT a, b, d, count(b), max(d) FROM test WHERE b IN (1, 2) and c IN (1, 2) GROUP BY a, b LIMIT 3 ALLOW FILTERING")) - self.assertEqual(res, [[1, 1, 2, 2L, 2], - [1, 2, 3, 2L, 3], - [2, 1, 3, 2L, 3]]) + assert res == [[1, 1, 2, 2, 2], + [1, 2, 3, 2, 3], + [2, 1, 3, 2, 3]] # Range queries with PER PARTITION LIMIT res = rows_to_list(session.execute("SELECT a, b, d, count(b), max(d) FROM test WHERE b = 1 and c IN (1, 2) GROUP BY a, b PER PARTITION LIMIT 2 ALLOW FILTERING")) - self.assertEqual(res, [[1, 1, 2, 2L, 2], - [2, 1, 3, 2L, 3], - [4, 1, 5, 2L, 5]]) + assert res == [[1, 1, 2, 2, 2], + [2, 1, 3, 2, 3], + [4, 1, 5, 2, 5]] res = rows_to_list(session.execute("SELECT a, b, d, count(b), max(d) FROM test WHERE b IN (1, 2) and c IN (1, 2) GROUP BY a, b PER PARTITION LIMIT 1 ALLOW FILTERING")) - self.assertEqual(res, [[1, 1, 2, 2L, 2], - [2, 1, 3, 2L, 3], - [4, 1, 5, 2L, 5]]) + assert res == [[1, 1, 2, 2, 2], + [2, 1, 3, 2, 3], + [4, 1, 5, 2, 5]] # Range queries with PER PARTITION LIMIT and LIMIT res = rows_to_list(session.execute("SELECT a, b, d, count(b), max(d) FROM test WHERE b = 1 and c IN (1, 2) GROUP BY a, b PER PARTITION LIMIT 2 LIMIT 5 ALLOW FILTERING")) - self.assertEqual(res, [[1, 1, 2, 2L, 2], - [2, 1, 3, 2L, 3], - [4, 1, 5, 2L, 5]]) + assert res == [[1, 1, 2, 2, 2], + [2, 1, 3, 2, 3], + [4, 1, 5, 2, 5]] res = rows_to_list(session.execute("SELECT a, b, d, count(b), max(d) FROM test WHERE b IN (1, 2) and c IN (1, 2) GROUP BY a, b PER PARTITION LIMIT 1 LIMIT 2 ALLOW FILTERING")) - self.assertEqual(res, [[1, 1, 2, 2L, 2], - [2, 1, 3, 2L, 3]]) + assert res == [[1, 1, 2, 2, 2], + [2, 1, 3, 2, 3]] @since('3.10') - def group_by_with_static_columns_paging_test(self): + def test_group_by_with_static_columns_paging(self): """ @jira_ticket CASSANDRA-10707 """ @@ -961,148 +962,148 @@ class TestPagingData(BasePagingTester, PageAssertionMixin): # Range queries res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test GROUP BY a")) - self.assertEqual(res, [[1, None, 1, 0L, 1L], - [2, None, 2, 0L, 1L], - [4, None, 3, 0L, 1L]]) + assert res == [[1, None, 1, 0, 1], + [2, None, 2, 0, 1], + [4, None, 3, 0, 1]] res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test GROUP BY a, b")) - self.assertEqual(res, [[1, None, 1, 0L, 1L], - [2, None, 2, 0L, 1L], - [4, None, 3, 0L, 1L]]) + assert res == [[1, None, 1, 0, 1], + [2, None, 2, 0, 1], + [4, None, 3, 0, 1]] res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test")) - self.assertEqual(res, [[1, None, 1, 0L, 3L]]) + assert res == [[1, None, 1, 0, 3]] # Range query without aggregates res = rows_to_list(session.execute("SELECT a, b, s FROM test GROUP BY a, b")) - self.assertEqual(res, [[1, None, 1], + assert res == [[1, None, 1], [2, None, 2], - [4, None, 3]]) + [4, None, 3]] # Range queries with LIMIT res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test GROUP BY a, b LIMIT 2")) - self.assertEqual(res, [[1, None, 1, 0L, 1L], - [2, None, 2, 0L, 1L]]) + assert res == [[1, None, 1, 0, 1], + [2, None, 2, 0, 1]] res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test LIMIT 2")) - self.assertEqual(res, [[1, None, 1, 0L, 3L]]) + assert res == [[1, None, 1, 0, 3]] # Range query with PER PARTITION LIMIT res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test GROUP BY a, b PER PARTITION LIMIT 2")) - self.assertEqual(res, [[1, None, 1, 0L, 1L], - [2, None, 2, 0L, 1L], - [4, None, 3, 0L, 1L]]) + assert res == [[1, None, 1, 0, 1], + [2, None, 2, 0, 1], + [4, None, 3, 0, 1]] # Range queries with DISTINCT res = rows_to_list(session.execute("SELECT DISTINCT a, s, count(s) FROM test GROUP BY a")) - self.assertEqual(res, [[1, 1, 1L], - [2, 2, 1L], - [4, 3, 1L]]) + assert res == [[1, 1, 1], + [2, 2, 1], + [4, 3, 1]] res = rows_to_list(session.execute("SELECT DISTINCT a, s, count(s) FROM test ")) - self.assertEqual(res, [[1, 1, 3L]]) + assert res == [[1, 1, 3]] # Range queries with DISTINCT and LIMIT res = rows_to_list(session.execute("SELECT DISTINCT a, s, count(s) FROM test GROUP BY a LIMIT 2")) - self.assertEqual(res, [[1, 1, 1L], - [2, 2, 1L]]) + assert res == [[1, 1, 1], + [2, 2, 1]] res = rows_to_list(session.execute("SELECT DISTINCT a, s, count(s) FROM test LIMIT 2")) - self.assertEqual(res, [[1, 1, 3L]]) + assert res == [[1, 1, 3]] # Single partition queries res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a = 1 GROUP BY a")) - self.assertEqual(res, [[1, None, 1, 0L, 1L]]) + assert res == [[1, None, 1, 0, 1]] res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a = 1 GROUP BY a, b")) - self.assertEqual(res, [[1, None, 1, 0L, 1L]]) + assert res == [[1, None, 1, 0, 1]] res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a = 1")) - self.assertEqual(res, [[1, None, 1, 0L, 1L]]) + assert res == [[1, None, 1, 0, 1]] # Single partition query without aggregates res = rows_to_list(session.execute("SELECT a, b, s FROM test WHERE a = 1 GROUP BY a, b")) - self.assertEqual(res, [[1, None, 1]]) + assert res == [[1, None, 1]] # Single partition queries with LIMIT res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a = 1 GROUP BY a, b LIMIT 2")) - self.assertEqual(res, [[1, None, 1, 0L, 1L]]) + assert res == [[1, None, 1, 0, 1]] res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a = 1 LIMIT 2")) - self.assertEqual(res, [[1, None, 1, 0L, 1L]]) + assert res == [[1, None, 1, 0, 1]] # Single partition queries with PER PARTITION LIMIT res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a = 1 GROUP BY a, b PER PARTITION LIMIT 2")) - self.assertEqual(res, [[1, None, 1, 0L, 1L]]) + assert res == [[1, None, 1, 0, 1]] # Single partition queries with DISTINCT res = rows_to_list(session.execute("SELECT DISTINCT a, s, count(s) FROM test WHERE a = 1 GROUP BY a")) - self.assertEqual(res, [[1, 1, 1L]]) + assert res == [[1, 1, 1]] res = rows_to_list(session.execute("SELECT DISTINCT a, s, count(s) FROM test WHERE a = 1")) - self.assertEqual(res, [[1, 1, 1L]]) + assert res == [[1, 1, 1]] # Multi-partitions queries res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a")) - self.assertEqual(res, [[1, None, 1, 0L, 1L], - [2, None, 2, 0L, 1L], - [4, None, 3, 0L, 1L]]) + assert res == [[1, None, 1, 0, 1], + [2, None, 2, 0, 1], + [4, None, 3, 0, 1]] res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a, b")) - self.assertEqual(res, [[1, None, 1, 0L, 1L], - [2, None, 2, 0L, 1L], - [4, None, 3, 0L, 1L]]) + assert res == [[1, None, 1, 0, 1], + [2, None, 2, 0, 1], + [4, None, 3, 0, 1]] res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4)")) - self.assertEqual(res, [[1, None, 1, 0L, 3L]]) + assert res == [[1, None, 1, 0, 3]] # Multi-partitions query without aggregates res = rows_to_list(session.execute("SELECT a, b, s FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a, b")) - self.assertEqual(res, [[1, None, 1], - [2, None, 2], - [4, None, 3]]) + assert res == [[1, None, 1], + [2, None, 2], + [4, None, 3]] # Multi-partitions query with LIMIT res = rows_to_list(session.execute( "SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a, b LIMIT 2")) - self.assertEqual(res, [[1, None, 1, 0L, 1L], - [2, None, 2, 0L, 1L]]) + assert res == [[1, None, 1, 0, 1], + [2, None, 2, 0, 1]] res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4) LIMIT 2")) - self.assertEqual(res, [[1, None, 1, 0L, 3L]]) + assert res == [[1, None, 1, 0, 3]] # Multi-partitions query with PER PARTITION LIMIT res = rows_to_list(session.execute( "SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a, b PER PARTITION LIMIT 1")) - self.assertEqual(res, [[1, None, 1, 0L, 1L], - [2, None, 2, 0L, 1L], - [4, None, 3, 0L, 1L]]) + assert res == [[1, None, 1, 0, 1], + [2, None, 2, 0, 1], + [4, None, 3, 0, 1]] # Multi-partitions queries with DISTINCT res = rows_to_list( session.execute("SELECT DISTINCT a, s, count(s) FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a")) - self.assertEqual(res, [[1, 1, 1L], - [2, 2, 1L], - [4, 3, 1L]]) + assert res == [[1, 1, 1], + [2, 2, 1], + [4, 3, 1]] res = rows_to_list(session.execute("SELECT DISTINCT a, s, count(s) FROM test WHERE a IN (1, 2, 3, 4)")) - self.assertEqual(res, [[1, 1, 3L]]) + assert res == [[1, 1, 3]] # Multi-partitions queries with DISTINCT and LIMIT res = rows_to_list( session.execute("SELECT DISTINCT a, s, count(s) FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a LIMIT 2")) - self.assertEqual(res, [[1, 1, 1L], - [2, 2, 1L]]) + assert res == [[1, 1, 1], + [2, 2, 1]] res = rows_to_list( session.execute("SELECT DISTINCT a, s, count(s) FROM test WHERE a IN (1, 2, 3, 4) LIMIT 2")) - self.assertEqual(res, [[1, 1, 3L]]) + assert res == [[1, 1, 3]] # ------------------------------------ # Test with non static columns not empty @@ -1129,331 +1130,330 @@ class TestPagingData(BasePagingTester, PageAssertionMixin): # Range queries res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test GROUP BY a")) - self.assertEqual(res, [[1, 2, 1, 4L, 4L], - [2, 2, 2, 2L, 2L], - [4, 8, None, 1L, 0L], - [3, None, 3, 0L, 1L]]) + assert res == [[1, 2, 1, 4, 4], + [2, 2, 2, 2, 2], + [4, 8, None, 1, 0], + [3, None, 3, 0, 1]] res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test GROUP BY a, b")) - self.assertEqual(res, [[1, 2, 1, 2L, 2L], - [1, 4, 1, 2L, 2L], - [2, 2, 2, 1L, 1L], - [2, 4, 2, 1L, 1L], - [4, 8, None, 1L, 0L], - [3, None, 3, 0L, 1L]]) + assert res == [[1, 2, 1, 2, 2], + [1, 4, 1, 2, 2], + [2, 2, 2, 1, 1], + [2, 4, 2, 1, 1], + [4, 8, None, 1, 0], + [3, None, 3, 0, 1]] res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test")) - self.assertEqual(res, [[1, 2, 1, 7L, 7L]]) + assert res == [[1, 2, 1, 7, 7]] res = rows_to_list( session.execute( "SELECT a, b, s, count(b), count(s) FROM test WHERE b = 2 GROUP BY a, b ALLOW FILTERING")) - self.assertEqual(res, [[1, 2, 1, 2L, 2L], - [2, 2, 2, 1L, 1L]]) + assert res == [[1, 2, 1, 2, 2], + [2, 2, 2, 1, 1]] assert_invalid(session, "SELECT a, b, s, count(b), count(s) FROM test WHERE b = 2 GROUP BY a, b", expected=InvalidRequest) res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE b = 2 ALLOW FILTERING")) - self.assertEqual(res, [[1, 2, 1, 3L, 3L]]) + assert res == [[1, 2, 1, 3, 3]] assert_invalid(session, "SELECT a, b, s, count(b), count(s) FROM test WHERE b = 2", expected=InvalidRequest) # Range queries without aggregates res = rows_to_list(session.execute("SELECT a, b, s FROM test GROUP BY a")) - self.assertEqual(res, [[1, 2, 1], - [2, 2, 2], - [4, 8, None], - [3, None, 3]]) + assert res == [[1, 2, 1], + [2, 2, 2], + [4, 8, None], + [3, None, 3]] res = rows_to_list(session.execute("SELECT a, b, s FROM test GROUP BY a, b")) - self.assertEqual(res, [[1, 2, 1], - [1, 4, 1], - [2, 2, 2], - [2, 4, 2], - [4, 8, None], - [3, None, 3]]) + assert res == [[1, 2, 1], + [1, 4, 1], + [2, 2, 2], + [2, 4, 2], + [4, 8, None], + [3, None, 3]] # Range query with LIMIT res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test GROUP BY a LIMIT 2")) - self.assertEqual(res, [[1, 2, 1, 4L, 4L], - [2, 2, 2, 2L, 2L]]) + assert res == [[1, 2, 1, 4, 4], + [2, 2, 2, 2, 2]] res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test LIMIT 2")) - self.assertEqual(res, [[1, 2, 1, 7L, 7L]]) + assert res == [[1, 2, 1, 7, 7]] # Range queries without aggregates and with LIMIT res = rows_to_list(session.execute("SELECT a, b, s FROM test GROUP BY a LIMIT 2")) - self.assertEqual(res, [[1, 2, 1], - [2, 2, 2]]) + assert res == [[1, 2, 1], + [2, 2, 2]] res = rows_to_list(session.execute("SELECT a, b, s FROM test GROUP BY a, b LIMIT 10")) - self.assertEqual(res, [[1, 2, 1], - [1, 4, 1], - [2, 2, 2], - [2, 4, 2], - [4, 8, None], - [3, None, 3]]) + assert res == [[1, 2, 1], + [1, 4, 1], + [2, 2, 2], + [2, 4, 2], + [4, 8, None], + [3, None, 3]] # Range queries with PER PARTITION LIMITS res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test GROUP BY a, b PER PARTITION LIMIT 2")) - self.assertEqual(res, [[1, 2, 1, 2L, 2L], - [1, 4, 1, 2L, 2L], - [2, 2, 2, 1L, 1L], - [2, 4, 2, 1L, 1L], - [4, 8, None, 1L, 0L], - [3, None, 3, 0L, 1L]]) + assert res == [[1, 2, 1, 2, 2], + [1, 4, 1, 2, 2], + [2, 2, 2, 1, 1], + [2, 4, 2, 1, 1], + [4, 8, None, 1, 0], + [3, None, 3, 0, 1]] res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test GROUP BY a, b PER PARTITION LIMIT 1")) - self.assertEqual(res, [[1, 2, 1, 2L, 2L], - [2, 2, 2, 1L, 1L], - [4, 8, None, 1L, 0L], - [3, None, 3, 0L, 1L]]) + assert res == [[1, 2, 1, 2, 2], + [2, 2, 2, 1, 1], + [4, 8, None, 1, 0], + [3, None, 3, 0, 1]] # Range queries with PER PARTITION LIMITS and LIMIT res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test GROUP BY a, b PER PARTITION LIMIT 1 LIMIT 5")) - self.assertEqual(res, [[1, 2, 1, 2L, 2L], - [2, 2, 2, 1L, 1L], - [4, 8, None, 1L, 0L], - [3, None, 3, 0L, 1L]]) + assert res == [[1, 2, 1, 2, 2], + [2, 2, 2, 1, 1], + [4, 8, None, 1, 0], + [3, None, 3, 0, 1]] res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test GROUP BY a, b PER PARTITION LIMIT 1 LIMIT 4")) - self.assertEqual(res, [[1, 2, 1, 2L, 2L], - [2, 2, 2, 1L, 1L], - [4, 8, None, 1L, 0L], - [3, None, 3, 0L, 1L]]) + assert res == [[1, 2, 1, 2, 2], + [2, 2, 2, 1, 1], + [4, 8, None, 1, 0], + [3, None, 3, 0, 1]] res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test GROUP BY a, b PER PARTITION LIMIT 1 LIMIT 2")) - self.assertEqual(res, [[1, 2, 1, 2L, 2L], - [2, 2, 2, 1L, 1L]]) + assert res == [[1, 2, 1, 2, 2], + [2, 2, 2, 1, 1]] # Range queries with DISTINCT res = rows_to_list(session.execute("SELECT DISTINCT a, s, count(a), count(s) FROM test GROUP BY a")) - self.assertEqual(res, [[1, 1, 1L, 1L], - [2, 2, 1L, 1L], - [4, None, 1L, 0L], - [3, 3, 1L, 1L]]) + assert res == [[1, 1, 1, 1], + [2, 2, 1, 1], + [4, None, 1, 0], + [3, 3, 1, 1]] res = rows_to_list(session.execute("SELECT DISTINCT a, s, count(a), count(s) FROM test")) - self.assertEqual(res, [[1, 1, 4L, 3L]]) + assert res == [[1, 1, 4, 3]] # Range queries with DISTINCT and LIMIT res = rows_to_list(session.execute("SELECT DISTINCT a, s, count(a), count(s) FROM test GROUP BY a LIMIT 2")) - self.assertEqual(res, [[1, 1, 1L, 1L], - [2, 2, 1L, 1L]]) + assert res == [[1, 1, 1, 1], + [2, 2, 1, 1]] res = rows_to_list(session.execute("SELECT DISTINCT a, s, count(a), count(s) FROM test LIMIT 2")) - self.assertEqual(res, [[1, 1, 4L, 3L]]) + assert res == [[1, 1, 4, 3]] # Single partition queries res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a = 1 GROUP BY a")) - self.assertEqual(res, [[1, 2, 1, 4L, 4L]]) + assert res == [[1, 2, 1, 4, 4]] res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a = 3 GROUP BY a, b")) - self.assertEqual(res, [[3, None, 3, 0L, 1L]]) + assert res == [[3, None, 3, 0, 1]] res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a = 3")) - self.assertEqual(res, [[3, None, 3, 0L, 1L]]) + assert res == [[3, None, 3, 0, 1]] res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a = 2 AND b = 2 GROUP BY a, b")) - self.assertEqual(res, [[2, 2, 2, 1L, 1L]]) + assert res == [[2, 2, 2, 1, 1]] res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a = 2 AND b = 2")) - self.assertEqual(res, [[2, 2, 2, 1L, 1L]]) + assert res == [[2, 2, 2, 1, 1]] # Single partition queries without aggregates res = rows_to_list(session.execute("SELECT a, b, s FROM test WHERE a = 1 GROUP BY a")) - self.assertEqual(res, [[1, 2, 1]]) + assert res == [[1, 2, 1]] res = rows_to_list(session.execute("SELECT a, b, s FROM test WHERE a = 4 GROUP BY a, b")) - self.assertEqual(res, [[4, 8, None]]) + assert res == [[4, 8, None]] # Single partition queries with LIMIT res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a = 2 GROUP BY a, b LIMIT 1")) - self.assertEqual(res, [[2, 2, 2, 1L, 1L]]) + assert res == [[2, 2, 2, 1, 1]] res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a = 2 LIMIT 1")) - self.assertEqual(res, [[2, 2, 2, 2L, 2L]]) + assert res == [[2, 2, 2, 2, 2]] # Single partition queries without aggregates and with LIMIT res = rows_to_list(session.execute("SELECT a, b, s FROM test WHERE a = 2 GROUP BY a, b LIMIT 1")) - self.assertEqual(res, [[2, 2, 2]]) + assert res == [[2, 2, 2]] res = rows_to_list(session.execute("SELECT a, b, s FROM test WHERE a = 2 GROUP BY a, b LIMIT 2")) - self.assertEqual(res, [[2, 2, 2], - [2, 4, 2]]) + assert res == [[2, 2, 2], + [2, 4, 2]] # Single partition queries with PER PARTITION LIMIT res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a = 2 GROUP BY a, b PER PARTITION LIMIT 1")) - self.assertEqual(res, [[2, 2, 2, 1L, 1L]]) + assert res == [[2, 2, 2, 1, 1]] # Single partition queries with DISTINCT res = rows_to_list( session.execute("SELECT DISTINCT a, s, count(a), count(s) FROM test WHERE a = 2 GROUP BY a")) - self.assertEqual(res, [[2, 2, 1L, 1L]]) + assert res == [[2, 2, 1, 1]] # Single partition queries with ORDER BY res = rows_to_list(session.execute( "SELECT a, b, s, count(b), count(s) FROM test WHERE a = 2 GROUP BY a, b ORDER BY b DESC, c DESC")) - self.assertEqual(res, [[2, 4, 2, 1L, 1L], - [2, 2, 2, 1L, 1L]]) + assert res == [[2, 4, 2, 1, 1], + [2, 2, 2, 1, 1]] res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a = 2 ORDER BY b DESC, c DESC")) - self.assertEqual(res, [[2, 4, 2, 2L, 2L]]) + assert res == [[2, 4, 2, 2, 2]] # Single partition queries with ORDER BY and LIMIT res = rows_to_list(session.execute( "SELECT a, b, s, count(b), count(s) FROM test WHERE a = 2 GROUP BY a, b ORDER BY b DESC, c DESC LIMIT 1")) - self.assertEqual(res, [[2, 4, 2, 1L, 1L]]) + assert res == [[2, 4, 2, 1, 1]] res = rows_to_list(session.execute( "SELECT a, b, s, count(b), count(s) FROM test WHERE a = 2 ORDER BY b DESC, c DESC LIMIT 2")) - self.assertEqual(res, [[2, 4, 2, 2L, 2L]]) + assert res == [[2, 4, 2, 2, 2]] # Single partition queries with ORDER BY and PER PARTITION LIMIT res = rows_to_list(session.execute( "SELECT a, b, s, count(b), count(s) FROM test WHERE a = 2 GROUP BY a, b ORDER BY b DESC, c DESC PER PARTITION LIMIT 1")) - self.assertEqual(res, [[2, 4, 2, 1L, 1L]]) + assert res == [[2, 4, 2, 1, 1]] # Multi-partitions queries res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a")) - self.assertEqual(res, [[1, 2, 1, 4L, 4L], - [2, 2, 2, 2L, 2L], - [3, None, 3, 0L, 1L], - [4, 8, None, 1L, 0L]]) + assert res == [[1, 2, 1, 4, 4], + [2, 2, 2, 2, 2], + [3, None, 3, 0, 1], + [4, 8, None, 1, 0]] res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a, b")) - self.assertEqual(res, [[1, 2, 1, 2L, 2L], - [1, 4, 1, 2L, 2L], - [2, 2, 2, 1L, 1L], - [2, 4, 2, 1L, 1L], - [3, None, 3, 0L, 1L], - [4, 8, None, 1L, 0L]]) + assert res == [[1, 2, 1, 2, 2], + [1, 4, 1, 2, 2], + [2, 2, 2, 1, 1], + [2, 4, 2, 1, 1], + [3, None, 3, 0, 1], + [4, 8, None, 1, 0]] res = rows_to_list(session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4)")) - self.assertEqual(res, [[1, 2, 1, 7L, 7L]]) + assert res == [[1, 2, 1, 7, 7]] res = rows_to_list(session.execute( "SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4) AND b = 2 GROUP BY a, b")) - self.assertEqual(res, [[1, 2, 1, 2L, 2L], - [2, 2, 2, 1L, 1L]]) + assert res == [[1, 2, 1, 2, 2], + [2, 2, 2, 1, 1]] res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4) AND b = 2")) - self.assertEqual(res, [[1, 2, 1, 3L, 3L]]) + assert res == [[1, 2, 1, 3, 3]] # Multi-partitions queries without aggregates res = rows_to_list(session.execute("SELECT a, b, s FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a")) - self.assertEqual(res, [[1, 2, 1], - [2, 2, 2], - [3, None, 3], - [4, 8, None]]) + assert res == [[1, 2, 1], + [2, 2, 2], + [3, None, 3], + [4, 8, None]] res = rows_to_list(session.execute("SELECT a, b, s FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a, b")) - self.assertEqual(res, [[1, 2, 1], - [1, 4, 1], - [2, 2, 2], - [2, 4, 2], - [3, None, 3], - [4, 8, None]]) + assert res == [[1, 2, 1], + [1, 4, 1], + [2, 2, 2], + [2, 4, 2], + [3, None, 3], + [4, 8, None]] # Multi-partitions queries with LIMIT res = rows_to_list(session.execute( "SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a LIMIT 2")) - self.assertEqual(res, [[1, 2, 1, 4L, 4L], - [2, 2, 2, 2L, 2L]]) + assert res == [[1, 2, 1, 4, 4], + [2, 2, 2, 2, 2]] res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4) LIMIT 2")) - self.assertEqual(res, [[1, 2, 1, 7L, 7L]]) + assert res == [[1, 2, 1, 7, 7]] # Multi-partitions queries without aggregates and with LIMIT res = rows_to_list(session.execute("SELECT a, b, s FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a LIMIT 2")) - self.assertEqual(res, [[1, 2, 1], - [2, 2, 2]]) + assert res == [[1, 2, 1], + [2, 2, 2]] res = rows_to_list( session.execute("SELECT a, b, s FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a, b LIMIT 10")) - self.assertEqual(res, [[1, 2, 1], - [1, 4, 1], - [2, 2, 2], - [2, 4, 2], - [3, None, 3], - [4, 8, None]]) + assert res == [[1, 2, 1], + [1, 4, 1], + [2, 2, 2], + [2, 4, 2], + [3, None, 3], + [4, 8, None]] # Multi-partitions queries with PER PARTITION LIMIT res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a PER PARTITION LIMIT 1")) - self.assertEqual(res, [[1, 2, 1, 4L, 4L], - [2, 2, 2, 2L, 2L], - [3, None, 3, 0L, 1L], - [4, 8, None, 1L, 0L]]) + assert res == [[1, 2, 1, 4, 4], + [2, 2, 2, 2, 2], + [3, None, 3, 0, 1], + [4, 8, None, 1, 0]] res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a, b PER PARTITION LIMIT 2")) - self.assertEqual(res, [[1, 2, 1, 2L, 2L], - [1, 4, 1, 2L, 2L], - [2, 2, 2, 1L, 1L], - [2, 4, 2, 1L, 1L], - [3, None, 3, 0L, 1L], - [4, 8, None, 1L, 0L]]) + assert res == [[1, 2, 1, 2, 2], + [1, 4, 1, 2, 2], + [2, 2, 2, 1, 1], + [2, 4, 2, 1, 1], + [3, None, 3, 0, 1], + [4, 8, None, 1, 0]] res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a, b PER PARTITION LIMIT 1")) - self.assertEqual(res, [[1, 2, 1, 2L, 2L], - [2, 2, 2, 1L, 1L], - [3, None, 3, 0L, 1L], - [4, 8, None, 1L, 0L]]) + assert res == [[1, 2, 1, 2, 2], + [2, 2, 2, 1, 1], + [3, None, 3, 0, 1], + [4, 8, None, 1, 0]] # Multi-partitions queries with DISTINCT res = rows_to_list(session.execute( "SELECT DISTINCT a, s, count(a), count(s) FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a")) - self.assertEqual(res, [[1, 1, 1L, 1L], - [2, 2, 1L, 1L], - [3, 3, 1L, 1L], - [4, None, 1L, 0L]]) + assert res == [[1, 1, 1, 1], + [2, 2, 1, 1], + [3, 3, 1, 1], + [4, None, 1, 0]] # Multi-partitions queries with PER PARTITION LIMIT and LIMIT res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a PER PARTITION LIMIT 1 LIMIT 3")) - self.assertEqual(res, [[1, 2, 1, 4L, 4L], - [2, 2, 2, 2L, 2L], - [3, None, 3, 0L, 1L]]) + assert res == [[1, 2, 1, 4, 4], + [2, 2, 2, 2, 2], + [3, None, 3, 0, 1]] res = rows_to_list( session.execute("SELECT a, b, s, count(b), count(s) FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a, b PER PARTITION LIMIT 2 LIMIT 3")) - self.assertEqual(res, [[1, 2, 1, 2L, 2L], - [1, 4, 1, 2L, 2L], - [2, 2, 2, 1L, 1L]]) + assert res == [[1, 2, 1, 2, 2], + [1, 4, 1, 2, 2], + [2, 2, 2, 1, 1]] res = rows_to_list( session.execute("SELECT DISTINCT a, s, count(a), count(s) FROM test WHERE a IN (1, 2, 3, 4)")) - self.assertEqual(res, [[1, 1, 4L, 3L]]) + assert res == [[1, 1, 4, 3]] # Multi-partitions query with DISTINCT and LIMIT res = rows_to_list(session.execute( "SELECT DISTINCT a, s, count(a), count(s) FROM test WHERE a IN (1, 2, 3, 4) GROUP BY a LIMIT 2")) - self.assertEqual(res, [[1, 1, 1L, 1L], - [2, 2, 1L, 1L]]) + assert res == [[1, 1, 1, 1], + [2, 2, 1, 1]] res = rows_to_list( session.execute("SELECT DISTINCT a, s, count(a), count(s) FROM test WHERE a IN (1, 2, 3, 4) LIMIT 2")) - self.assertEqual(res, [[1, 1, 4L, 3L]]) + assert res == [[1, 1, 4, 3]] @since('2.0.6') - def static_columns_paging_test(self): + def test_static_columns_paging(self): """ Exercises paging with static columns to detect bugs @jira_ticket CASSANDRA-8502. """ - session = self.prepare(row_factory=named_tuple_factory) create_ks(session, 'test_paging_static_cols', 2) session.execute("CREATE TABLE test (a int, b int, c int, s1 int static, s2 int static, PRIMARY KEY (a, b))") @@ -1472,186 +1472,186 @@ class TestPagingData(BasePagingTester, PageAssertionMixin): PAGE_SIZES = (2, 3, 4, 5, 15, 16, 17, 100) for page_size in PAGE_SIZES: - debug("Current page size is {}".format(page_size)) + logger.debug("Current page size is {}".format(page_size)) session.default_fetch_size = page_size for selector in selectors: results = list(session.execute("SELECT %s FROM test" % selector)) assert_length_equal(results, 16) - self.assertEqual([0] * 4 + [1] * 4 + [2] * 4 + [3] * 4, sorted([r.a for r in results])) - self.assertEqual([0, 1, 2, 3] * 4, [r.b for r in results]) - self.assertEqual([0, 1, 2, 3] * 4, [r.c for r in results]) + assert [0] * 4 + [1] * 4 + [2] * 4 + [3] * 4 == sorted([r.a for r in results]) + assert [0, 1, 2, 3] * 4 == [r.b for r in results] + assert [0, 1, 2, 3] * 4 == [r.c for r in results] if "s1" in selector: - self.assertEqual([17] * 16, [r.s1 for r in results]) + assert [17] * 16 == [r.s1 for r in results] if "s2" in selector: - self.assertEqual([42] * 16, [r.s2 for r in results]) + assert [42] * 16 == [r.s2 for r in results] # IN over the partitions for page_size in PAGE_SIZES: - debug("Current page size is {}".format(page_size)) + logger.debug("Current page size is {}".format(page_size)) session.default_fetch_size = page_size for selector in selectors: results = list(session.execute("SELECT %s FROM test WHERE a IN (0, 1, 2, 3)" % selector)) assert_length_equal(results, 16) - self.assertEqual([0] * 4 + [1] * 4 + [2] * 4 + [3] * 4, sorted([r.a for r in results])) - self.assertEqual([0, 1, 2, 3] * 4, [r.b for r in results]) - self.assertEqual([0, 1, 2, 3] * 4, [r.c for r in results]) + assert [0] * 4 + [1] * 4 + [2] * 4 + [3] * 4 == sorted([r.a for r in results]) + assert [0, 1, 2, 3] * 4 == [r.b for r in results] + assert [0, 1, 2, 3] * 4 == [r.c for r in results] if "s1" in selector: - self.assertEqual([17] * 16, [r.s1 for r in results]) + assert [17] * 16 == [r.s1 for r in results] if "s2" in selector: - self.assertEqual([42] * 16, [r.s2 for r in results]) + assert [42] * 16 == [r.s2 for r in results] # single partition for i in range(16): session.execute("INSERT INTO test (a, b, c, s1, s2) VALUES (%d, %d, %d, %d, %d)" % (99, i, i, 17, 42)) for page_size in PAGE_SIZES: - debug("Current page size is {}".format(page_size)) + logger.debug("Current page size is {}".format(page_size)) session.default_fetch_size = page_size for selector in selectors: results = list(session.execute("SELECT %s FROM test WHERE a = 99" % selector)) assert_length_equal(results, 16) - self.assertEqual([99] * 16, [r.a for r in results]) - self.assertEqual(range(16), [r.b for r in results]) - self.assertEqual(range(16), [r.c for r in results]) + assert [99] * 16 == [r.a for r in results] + assert list(range(16)) == [r.b for r in results] + assert list(range(16)) == [r.c for r in results] if "s1" in selector: - self.assertEqual([17] * 16, [r.s1 for r in results]) + assert [17] * 16 == [r.s1 for r in results] if "s2" in selector: - self.assertEqual([42] * 16, [r.s2 for r in results]) + assert [42] * 16 == [r.s2 for r in results] # reversed for page_size in PAGE_SIZES: - debug("Current page size is {}".format(page_size)) + logger.debug("Current page size is {}".format(page_size)) session.default_fetch_size = page_size for selector in selectors: results = list(session.execute("SELECT %s FROM test WHERE a = 99 ORDER BY b DESC" % selector)) assert_length_equal(results, 16) - self.assertEqual([99] * 16, [r.a for r in results]) - self.assertEqual(list(reversed(range(16))), [r.b for r in results]) - self.assertEqual(list(reversed(range(16))), [r.c for r in results]) + assert [99] * 16 == [r.a for r in results] + assert list(reversed(list(range(16)))) == [r.b for r in results] + assert list(reversed(list(range(16)))) == [r.c for r in results] if "s1" in selector: - self.assertEqual([17] * 16, [r.s1 for r in results]) + assert [17] * 16 == [r.s1 for r in results] if "s2" in selector: - self.assertEqual([42] * 16, [r.s2 for r in results]) + assert [42] * 16 == [r.s2 for r in results] # IN on clustering column for page_size in PAGE_SIZES: - debug("Current page size is {}".format(page_size)) + logger.debug("Current page size is {}".format(page_size)) session.default_fetch_size = page_size for selector in selectors: results = list(session.execute("SELECT %s FROM test WHERE a = 99 AND b IN (3, 4, 8, 14, 15)" % selector)) assert_length_equal(results, 5) - self.assertEqual([99] * 5, [r.a for r in results]) - self.assertEqual([3, 4, 8, 14, 15], [r.b for r in results]) - self.assertEqual([3, 4, 8, 14, 15], [r.c for r in results]) + assert [99] * 5 == [r.a for r in results] + assert [3, 4, 8, 14, 15] == [r.b for r in results] + assert [3, 4, 8, 14, 15] == [r.c for r in results] if "s1" in selector: - self.assertEqual([17] * 5, [r.s1 for r in results]) + assert [17] * 5 == [r.s1 for r in results] if "s2" in selector: - self.assertEqual([42] * 5, [r.s2 for r in results]) + assert [42] * 5 == [r.s2 for r in results] # reversed IN on clustering column for page_size in PAGE_SIZES: - debug("Current page size is {}".format(page_size)) + logger.debug("Current page size is {}".format(page_size)) session.default_fetch_size = page_size for selector in selectors: results = list(session.execute("SELECT %s FROM test WHERE a = 99 AND b IN (3, 4, 8, 14, 15) ORDER BY b DESC" % selector)) assert_length_equal(results, 5) - self.assertEqual([99] * 5, [r.a for r in results]) - self.assertEqual(list(reversed([3, 4, 8, 14, 15])), [r.b for r in results]) - self.assertEqual(list(reversed([3, 4, 8, 14, 15])), [r.c for r in results]) + assert [99] * 5 == [r.a for r in results] + assert list(reversed([3, 4, 8, 14, 15])) == [r.b for r in results] + assert list(reversed([3, 4, 8, 14, 15])) == [r.c for r in results] if "s1" in selec
<TRUNCATED> --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org