Exemplo n.º 1
0
    async def test_progressive_unsupported_async(self):
        with self.open_async_json_file("progressive_result.json") as f:
            reader = AsyncProgressiveDataSetEnumerator(AsyncJsonTokenReader(f))

            with pytest.raises(KustoUnsupportedApiError):
                async for _ in reader:
                    pass

        with self.open_async_json_file(
                "deft_with_progressive_result.json") as f:
            reader = AsyncProgressiveDataSetEnumerator(AsyncJsonTokenReader(f))

            with pytest.raises(KustoUnsupportedApiError):
                async for _ in reader:
                    pass
Exemplo n.º 2
0
    async def test_sanity_kusto_streaming_response_dataset_async(self):
        with self.open_async_json_file("deft.json") as f:
            reader = AsyncProgressiveDataSetEnumerator(AsyncJsonTokenReader(f))

            response = AsyncKustoStreamingResponseDataSet(reader)
            primary_tables = response.iter_primary_results()

            # Before reading all of the tables these results won't be available
            with pytest.raises(KustoStreamingQueryError):
                errors_count = response.errors_count
            with pytest.raises(KustoStreamingQueryError):
                exceptions = response.get_exceptions()

            first_table = await primary_tables.__anext__()

            # Can't advance by default until current table is finished
            with pytest.raises(KustoStreamingQueryError):
                await primary_tables.__anext__()

            self._assert_sanity_query_primary_results(
                [x async for x in first_table])

            with pytest.raises(StopAsyncIteration):
                await primary_tables.__anext__()
            assert response.errors_count == 0
            assert response.get_exceptions() == []

            assert response.finished
Exemplo n.º 3
0
 async def test_dynamic_async(self):
     with self.open_async_json_file("dynamic.json") as f:
         reader = AsyncProgressiveDataSetEnumerator(AsyncJsonTokenReader(f))
         async for i in reader:
             if i["FrameType"] == FrameType.DataTable and i[
                     "TableKind"] == WellKnownDataSet.PrimaryResult.value:
                 row = await i["Rows"].__anext__()
                 self._assert_dynamic_response(row)
Exemplo n.º 4
0
    async def test_exception_in_row_async(self):
        with self.open_async_json_file(
                "query_partial_results_defer_is_false.json") as f:
            reader = AsyncProgressiveDataSetEnumerator(AsyncJsonTokenReader(f))

            response = AsyncKustoStreamingResponseDataSet(reader)
            table = await response.iter_primary_results().__anext__()
            with pytest.raises(KustoMultiApiError):
                rows = [r async for r in table]
Exemplo n.º 5
0
    async def test_alternative_order_async(self):
        with self.open_async_json_file("alternative_order.json") as f:
            reader = AsyncProgressiveDataSetEnumerator(AsyncJsonTokenReader(f))

            async for i in reader:
                if i["FrameType"] == FrameType.DataTable and i[
                        "TableKind"] == WellKnownDataSet.PrimaryResult.value:
                    columns = [
                        KustoResultColumn(column, index)
                        for index, column in enumerate(i["Columns"])
                    ]
                    rows = [
                        KustoResultRow(columns, r) async for r in i["Rows"]
                    ]
                    self._assert_sanity_query_primary_results(rows)
Exemplo n.º 6
0
 def get_async_reader(self, data) -> AsyncJsonTokenReader:
     return AsyncJsonTokenReader(AsyncStringIO(data))