|
13 | 13 | from azure.kusto.data._models import KustoResultRow, KustoResultTable, KustoStreamingResultTable |
14 | 14 | from azure.kusto.data.response import WellKnownDataSet, KustoStreamingResponseDataSet, KustoResponseDataSet |
15 | 15 |
|
16 | | -PANDAS = False |
17 | | -try: |
18 | | - import pandas |
19 | | - |
20 | | - PANDAS = True |
21 | | -except: |
22 | | - pass |
| 16 | +from pandas import DataFrame, Series, to_datetime |
| 17 | +from pandas.testing import assert_frame_equal |
23 | 18 |
|
24 | 19 |
|
25 | 20 | def mocked_requests_post(*args, **kwargs): |
@@ -275,10 +270,7 @@ def _assert_sanity_control_command_response(response: SyncResponseSet): |
275 | 270 | assert result["ServiceType"] == "Engine" |
276 | 271 | assert result["ProductVersion"] == "KustoMain_2018.04.29.5" |
277 | 272 |
|
278 | | - def _assert_sanity_data_frame_response(self, data_frame: "pandas.DataFrame"): |
279 | | - from pandas import DataFrame, Series |
280 | | - from pandas.testing import assert_frame_equal |
281 | | - |
| 273 | + def _assert_sanity_data_frame_response(self, data_frame: "DataFrame"): |
282 | 274 | assert len(data_frame.columns) == 19 |
283 | 275 | expected_dict = { |
284 | 276 | "rownumber": Series([None, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype="Int32"), |
@@ -310,17 +302,17 @@ def _assert_sanity_data_frame_response(self, data_frame: "pandas.DataFrame"): |
310 | 302 | "xuint64": Series([None, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9], dtype="Int64"), |
311 | 303 | "xdate": Series( |
312 | 304 | [ |
313 | | - pandas.to_datetime(None), |
314 | | - pandas.to_datetime("2014-01-01T01:01:01.0000000Z"), |
315 | | - pandas.to_datetime("2015-01-01T01:01:01.0000001Z"), |
316 | | - pandas.to_datetime("2016-01-01T01:01:01.0000002Z"), |
317 | | - pandas.to_datetime("2017-01-01T01:01:01.0000003Z"), |
318 | | - pandas.to_datetime("2018-01-01T01:01:01.0000004Z"), |
319 | | - pandas.to_datetime("2019-01-01T01:01:01.0000005Z"), |
320 | | - pandas.to_datetime("2020-01-01T01:01:01.0000006Z"), |
321 | | - pandas.to_datetime("2021-01-01T01:01:01.0000007Z"), |
322 | | - pandas.to_datetime("2022-01-01T01:01:01.0000008Z"), |
323 | | - pandas.to_datetime("2023-01-01T01:01:01.0000009Z"), |
| 305 | + to_datetime(None), |
| 306 | + to_datetime("2014-01-01T01:01:01.0000000Z"), |
| 307 | + to_datetime("2015-01-01T01:01:01.0000001Z"), |
| 308 | + to_datetime("2016-01-01T01:01:01.0000002Z"), |
| 309 | + to_datetime("2017-01-01T01:01:01.0000003Z"), |
| 310 | + to_datetime("2018-01-01T01:01:01.0000004Z"), |
| 311 | + to_datetime("2019-01-01T01:01:01.0000005Z"), |
| 312 | + to_datetime("2020-01-01T01:01:01.0000006Z"), |
| 313 | + to_datetime("2021-01-01T01:01:01.0000007Z"), |
| 314 | + to_datetime("2022-01-01T01:01:01.0000008Z"), |
| 315 | + to_datetime("2023-01-01T01:01:01.0000009Z"), |
324 | 316 | ] |
325 | 317 | ), |
326 | 318 | "xsmalltext": Series(["", "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"], dtype=object), |
@@ -390,7 +382,7 @@ def _assert_partial_results_response(response: SyncResponseSet): |
390 | 382 | assert len(results) == 5 |
391 | 383 | assert results[0]["x"] == 1 |
392 | 384 |
|
393 | | - if type(response) == KustoStreamingResponseDataSet: |
| 385 | + if isinstance(response, KustoStreamingResponseDataSet): |
394 | 386 | _ = [t for t in response] # Read rest of tables |
395 | 387 | assert response.errors_count == 1 |
396 | 388 | assert "E_QUERY_RESULT_SET_TOO_LARGE" in response.get_exceptions()[0] |
|
0 commit comments