Skip to content

Commit 98b0984

Browse files
fix: replace module replacement with concrete mock instance in executemany test
without this the call_args are not logged on the instance and the unit test fails Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent cbaa1f3 commit 98b0984

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

tests/unit/test_client.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,30 +334,30 @@ def test_execute_parameter_passthrough(self):
334334
expected_query,
335335
)
336336

337-
@patch("%s.client.ThriftDatabricksClient" % PACKAGE_NAME)
338337
@patch("%s.client.ResultSet" % PACKAGE_NAME)
339338
def test_executemany_parameter_passhthrough_and_uses_last_result_set(
340-
self, mock_result_set_class, mock_thrift_backend
339+
self, mock_result_set_class
341340
):
342341
# Create a new mock result set each time the class is instantiated
343342
mock_result_set_instances = [Mock(), Mock(), Mock()]
344343
mock_result_set_class.side_effect = mock_result_set_instances
345344
mock_backend = ThriftDatabricksClientMockFactory.new()
346-
cursor = client.Cursor(Mock(), mock_backend())
345+
346+
cursor = client.Cursor(Mock(), mock_backend)
347347

348348
params = [{"x": None}, {"x": "foo1"}, {"x": "bar2"}]
349349
expected_queries = ["SELECT NULL", "SELECT 'foo1'", "SELECT 'bar2'"]
350350

351351
cursor.executemany("SELECT %(x)s", seq_of_parameters=params)
352352

353353
self.assertEqual(
354-
len(mock_thrift_backend.execute_command.call_args_list),
354+
len(mock_backend.execute_command.call_args_list),
355355
len(expected_queries),
356356
"Expected execute_command to be called the same number of times as params were passed",
357357
)
358358

359359
for expected_query, call_args in zip(
360-
expected_queries, mock_thrift_backend.execute_command.call_args_list
360+
expected_queries, mock_backend.execute_command.call_args_list
361361
):
362362
self.assertEqual(call_args[1]["operation"], expected_query)
363363

0 commit comments

Comments
 (0)