File: disable_test_events.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 (55 lines) | stat: -rw-r--r-- 2,130 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
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from azure.applicationinsights import ApplicationInsightsDataClient
from azure.applicationinsights.models import MetricsPostBodySchema, MetricsPostBodySchemaParameters
from devtools_testutils import AzureMgmtTestCase

class ApplicationInsightsEventsTest(AzureMgmtTestCase):
    def setUp(self):
        super(ApplicationInsightsEventsTest, self).setUp()
        self.client = self.create_basic_client(ApplicationInsightsDataClient) 
        self.application = 'DEMO_APP'
        self.props = [
            'id', 
            'timestamp', 
            'count', 
            'custom_dimensions', 
            'operation', 
            'session', 
            'user', 
            'cloud', 
            'ai', 
            'application', 
            'client', 
            'type'
        ]
        self.noneProps = ['interval', 'segments']

    def test_events_get_by_type(self):
        eventType = 'requests'
        result = self.client.events.get_by_type(self.application, eventType)
        self.assertIsNotNone(result.value)
        self.assertGreaterEqual(len(result.value), 1)
        self.assertTrue(hasattr(result, 'value'))
        self.check_props(result)
        
    def test_events_get(self):
        eventType = 'requests'
        eventId = '923e9660-7385-11e8-80fe-b756f505275f'
        result = self.client.events.get(self.application, eventType, eventId)
        self.assertIsNotNone(result.value)
        self.assertEqual(len(result.value), 1)
        self.assertEqual(result.value[0].id, eventId)
        self.check_props(result)

    def test_events_get_odata_metadata(self):
        result = self.client.events.get_odata_metadata(self.application, raw = True)
        self.assertIsNotNone(result)
        self.assertEqual(result.response.status_code, 200)
        self.assertIsNotNone(result.output)
        
    def check_props(self, result):
        self.assertTrue(hasattr(result, 'value'))
        for item in result.value:
            for prop in self.props:
                self.assertTrue(hasattr(item, prop))
            for prop in self.noneProps:
                self.assertFalse(hasattr(item, prop))