|
6 | 6 |
|
7 | 7 | import codecs |
8 | 8 | import os |
| 9 | +from six import PY2 |
9 | 10 | from io import StringIO, BytesIO |
10 | 11 |
|
| 12 | +if PY2: |
| 13 | + from mock import patch |
| 14 | +else: |
| 15 | + from unittest.mock import patch |
11 | 16 | import pytest |
12 | 17 |
|
13 | 18 | from snowflake.connector import ProgrammingError |
@@ -70,6 +75,25 @@ def test_execute_string(conn_cnx, db_parameters): |
70 | 75 | tbl2=db_parameters['name'] + '2'), return_cursors=False) |
71 | 76 |
|
72 | 77 |
|
| 78 | +def test_execute_string_kwargs(conn_cnx, db_parameters): |
| 79 | + with conn_cnx() as cnx: |
| 80 | + with patch('snowflake.connector.cursor.SnowflakeCursor.execute', autospec=True) as mock_execute: |
| 81 | + cnx.execute_string(""" |
| 82 | +CREATE OR REPLACE TABLE {tbl1} (c1 int, c2 string); |
| 83 | +CREATE OR REPLACE TABLE {tbl2} (c1 int, c2 string); |
| 84 | +INSERT INTO {tbl1} VALUES(1,'test123'); |
| 85 | +INSERT INTO {tbl1} VALUES(2,'test234'); |
| 86 | +INSERT INTO {tbl1} VALUES(3,'test345'); |
| 87 | +INSERT INTO {tbl2} VALUES(101,'test123'); |
| 88 | +INSERT INTO {tbl2} VALUES(102,'test234'); |
| 89 | +INSERT INTO {tbl2} VALUES(103,'test345'); |
| 90 | + """.format( |
| 91 | + tbl1=db_parameters['name'] + '1', |
| 92 | + tbl2=db_parameters['name'] + '2'), return_cursors=False, _no_results=True) |
| 93 | + for call in mock_execute.call_args_list: |
| 94 | + assert call[1].get('_no_results', False) |
| 95 | + |
| 96 | + |
73 | 97 | def test_execute_string_with_error(conn_cnx): |
74 | 98 | with conn_cnx() as cnx: |
75 | 99 | with pytest.raises(ProgrammingError): |
|
0 commit comments