Skip to content

Commit 385baa1

Browse files
committed
Trace test updates for PYTHON-318
1 parent 5957a65 commit 385baa1

3 files changed

Lines changed: 14 additions & 11 deletions

File tree

tests/integration/standard/test_client_warnings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def test_warning_with_trace(self):
9191
future.result()
9292
self.assertEqual(len(future.warnings), 1)
9393
self.assertRegexpMatches(future.warnings[0], 'Batch.*exceeding.*')
94-
self.assertIsNotNone(future._query_trace)
94+
self.assertIsNotNone(future.get_query_trace())
9595

9696
def test_warning_with_custom_payload(self):
9797
"""
@@ -127,5 +127,5 @@ def test_warning_with_trace_and_custom_payload(self):
127127
future.result()
128128
self.assertEqual(len(future.warnings), 1)
129129
self.assertRegexpMatches(future.warnings[0], 'Batch.*exceeding.*')
130-
self.assertIsNotNone(future._query_trace)
130+
self.assertIsNotNone(future.get_query_trace())
131131
self.assertDictEqual(future.custom_payload, payload)

tests/integration/standard/test_cluster.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -438,11 +438,11 @@ def test_trace(self):
438438
session = cluster.connect()
439439

440440
def check_trace(trace):
441-
self.assertIsNot(None, trace.request_type)
442-
self.assertIsNot(None, trace.duration)
443-
self.assertIsNot(None, trace.started_at)
444-
self.assertIsNot(None, trace.coordinator)
445-
self.assertIsNot(None, trace.events)
441+
self.assertIsNotNone(trace.request_type)
442+
self.assertIsNotNone(trace.duration)
443+
self.assertIsNotNone(trace.started_at)
444+
self.assertIsNotNone(trace.coordinator)
445+
self.assertIsNotNone(trace.events)
446446

447447
result = session.execute( "SELECT * FROM system.local", trace=True)
448448
check_trace(result.get_query_trace())

tests/unit/test_resultset.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def test_iter_paged(self):
3737
response_future.result.side_effect = (ResultSet(Mock(), expected[-5:]), ) # ResultSet is iterable, so it must be protected in order to be returned whole by the Mock
3838
rs = ResultSet(response_future, expected[:5])
3939
itr = iter(rs)
40-
type(response_future).has_more_pages = PropertyMock(side_effect=(True, False)) # after init to avoid side effects being consumed by init
40+
# this is brittle, depends on internal impl details. Would like to find a better way
41+
type(response_future).has_more_pages = PropertyMock(side_effect=(True, True, False)) # after init to avoid side effects being consumed by init
4142
self.assertListEqual(list(itr), expected)
4243

4344
def test_list_non_paged(self):
@@ -54,7 +55,8 @@ def test_list_paged(self):
5455
response_future = Mock(has_more_pages=True)
5556
response_future.result.side_effect = (ResultSet(Mock(), expected[-5:]), ) # ResultSet is iterable, so it must be protected in order to be returned whole by the Mock
5657
rs = ResultSet(response_future, expected[:5])
57-
type(response_future).has_more_pages = PropertyMock(side_effect=(True, True, False)) # one True for getitem check/warn, then True, False for two pages
58+
# this is brittle, depends on internal impl details. Would like to find a better way
59+
type(response_future).has_more_pages = PropertyMock(side_effect=(True, True, True, False)) # First two True are consumed on check entering list mode
5860
self.assertEqual(rs[9], expected[9])
5961
self.assertEqual(list(rs), expected)
6062

@@ -119,7 +121,8 @@ def test_index_list_mode(self):
119121
response_future = Mock(has_more_pages=True)
120122
response_future.result.side_effect = (ResultSet(Mock(), expected[-5:]), ) # ResultSet is iterable, so it must be protected in order to be returned whole by the Mock
121123
rs = ResultSet(response_future, expected[:5])
122-
type(response_future).has_more_pages = PropertyMock(side_effect=(True, True, False)) # First True is consumed on check entering list mode
124+
# this is brittle, depends on internal impl details. Would like to find a better way
125+
type(response_future).has_more_pages = PropertyMock(side_effect=(True, True, True, False)) # First two True are consumed on check entering list mode
123126
# index access before iteration causes list to be materialized
124127
self.assertEqual(rs[0], expected[0])
125128
self.assertEqual(rs[9], expected[9])
@@ -146,7 +149,7 @@ def test_eq(self):
146149
response_future = Mock(has_more_pages=True)
147150
response_future.result.side_effect = (ResultSet(Mock(), expected[-5:]), ) # ResultSet is iterable, so it must be protected in order to be returned whole by the Mock
148151
rs = ResultSet(response_future, expected[:5])
149-
type(response_future).has_more_pages = PropertyMock(side_effect=(True, True, False))
152+
type(response_future).has_more_pages = PropertyMock(side_effect=(True, True, True, False))
150153
# eq before iteration causes list to be materialized
151154
self.assertEqual(rs, expected)
152155

0 commit comments

Comments
 (0)