File: disable_test_log_query.py

package info (click to toggle)
python-azure 20230112%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 749,544 kB
  • sloc: python: 6,815,827; javascript: 287; makefile: 195; xml: 109; sh: 105
file content (22 lines) | stat: -rw-r--r-- 987 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from azure.applicationinsights import ApplicationInsightsDataClient
from azure.applicationinsights.models import QueryBody
from devtools_testutils import AzureMgmtTestCase

class ApplicationInsightsQueryTest(AzureMgmtTestCase):
    def setUp(self):
        super(ApplicationInsightsQueryTest, self).setUp()
        self.client = self.create_basic_client(ApplicationInsightsDataClient) 

    def test_query(self):
        query = 'requests | take 10'
        application = 'DEMO_APP'
        result = self.client.query.execute(application, QueryBody(query = query))
        # All queries should return at least a table.
        self.assertGreaterEqual(len(result.tables), 1)

        # Request table schema has 37 columns.
        self.assertEqual(len(result.tables[0].columns), 37)

        # The application should contain enough data to retrieve 10 rows, as asked
        self.assertEqual(len(result.tables[0].rows), 10)
        self.assertIs(type(result.tables[0].rows[0][7]), float)