| 224 | |
| 225 | |
| 226 | class TestMssqlCliClientMultipleStatement(MssqlCliClient): |
| 227 | test_data = [ |
| 228 | # random strings used to test for errors with non-existing tables |
| 229 | (u"select 'Morning' as [Name] UNION ALL select 'Evening'; " + |
| 230 | u"select 1;", [2, 1]), |
| 231 | (u"select 1; select 'foo' from %s;" % random_str(), [1, 0]), |
| 232 | (u"select 'foo' from %s; select 2;" % random_str(), [0, 1]) |
| 233 | ] |
| 234 | |
| 235 | @staticmethod |
| 236 | @pytest.mark.parametrize("query_str, rows_outputted", test_data) |
| 237 | def test_mssqlcliclient_multiple_statement(client, query_str, rows_outputted): |
| 238 | """ |
| 239 | Verify correct execution of queries separated by semi-colon |
| 240 | """ |
| 241 | |
| 242 | for (i, (rows, _, _, query_executed, is_error)) in \ |
| 243 | enumerate(client.execute_query(query_str)): |
| 244 | |
| 245 | queries = ["{};".format(query) for query in query_str.split(';')] |
| 246 | assert query_executed == queries[i].strip() |
| 247 | assert len(rows) == rows_outputted[i] |
| 248 | assert (is_error and len(rows) == 0) or (not is_error) |
| 249 | |
| 250 | @staticmethod |
| 251 | def test_mssqlcliclient_multiple_merge(client_with_db): |
| 252 | """ |
| 253 | Tests query with multiple merges. Requires creation of temp db. |
| 254 | """ |
| 255 | file_input, _ = get_io_paths('multiple_merge.txt') |
| 256 | query_input = get_file_contents(file_input) |
| 257 | |
| 258 | for rows, _, status, _, is_error in client_with_db.execute_query(query_input): |
| 259 | if is_error: |
| 260 | raise AssertionError("Query execution failed: {}".format(status)) |
| 261 | assert () == rows |
nothing calls this directly
no test coverage detected