File: disable_test_mgmt_botservice_connections.py

package info (click to toggle)
python-azure 20250603%2Bgit-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 851,724 kB
  • sloc: python: 7,362,925; ansic: 804; javascript: 287; makefile: 195; sh: 145; xml: 109
file content (111 lines) | stat: -rw-r--r-- 4,374 bytes parent folder | download | duplicates (2)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import unittest

from devtools_testutils import AzureMgmtTestCase, ResourceGroupPreparer
from azure.mgmt.botservice import AzureBotService
from azure.mgmt.botservice.models import (
    Bot,
    BotProperties,
    Sku
)

class BotServiceConnectionsTestCase(AzureMgmtTestCase):
    def setUp(self):
        super(BotServiceConnectionsTestCase, self).setUp()
        #create a bot here
        self.client = self.create_mgmt_client(AzureBotService)
        self.resource_name = self.get_resource_name('azurebot')
    
    def createBot(self):
        location = 'global'
        sku_name = 'Free'
        kind= 'Bot'
        display_name = "this is a test bot"
        description= "this is a description for a test bot"
        endpoint = "https://bing.com/messages/"
        msa_app_id = ""
        developer_app_insight_key = ''
        developer_app_insights_api_key = ''
        developer_app_insights_application_id = ''
        bot = self.client.bots.create(
            resource_group_name = self.resource_group_name,
            resource_name = self.resource_name,
            parameters = Bot(
                location= location,
                sku = sku.Sku(name=sku_name),
                kind= kind,
                properties= BotProperties(
                    display_name = display_name,
                    description= description,
                    endpoint = endpoint,
                    msa_app_id = msa_app_id,
                    developer_app_insight_key = developer_app_insight_key,
                    developer_app_insights_api_key = developer_app_insights_api_key,
                    developer_app_insights_application_id = developer_app_insights_application_id,
                )
            )
        )
    
    def tearDown(self):
        super(BotServiceConnectionsTestCase, self).tearDown()


    @unittest.skip("skip")
    @ResourceGroupPreparer(name_prefix='python_conn')
    def test_bot_connection_operations(self, resource_group):
        self.resource_group_name = resource_group.name
        self.createBot()
        from azure.mgmt.botservice.models import ConnectionSetting, ConnectionSettingProperties, ConnectionSettingParameter
        connection_resource_name = self.get_resource_name('myconnection')
        # create a connection
        setting_payload = ConnectionSetting(
            location='global',
            properties=ConnectionSettingProperties(
                client_id='clientId',
                client_secret='clientSecret',
                scopes='read,write',
                service_provider_id='',
                parameters=[ConnectionSettingParameter(key='key1', value='value1')]
            )
        )
        setting = self.client.bot_connection.create(
            resource_group_name=resource_group.name,
            resource_name=self.resource_name,
            connection_name=connection_resource_name,
            parameters=setting_payload
        )
        self.assertIsNotNone(setting)
        self.assertEqual(setting.properties.client_id, 'clientId')

        # get a connection
        setting = self.client.bot_connection.get(
            resource_group_name=resource_group.name,
            resource_name=self.resource_name,
            connection_name=connection_resource_name
        )
        self.assertIsNotNone(setting)
        #list all connections
        settings = self.client.bot_connection.list_by_bot_service(
            resource_group_name = resource_group.name,
            resource_name=self.resource_name
        )
        self.assertIsNotNone(setting)
        self.assertTrue(len(list(settings)) == 1)

        # delete a connection
        setting = self.client.bot_connection.delete(
            resource_group_name=resource_group.name,
            resource_name=self.resource_name,
            connection_name=connection_resource_name
        )
        with self.assertRaises(ErrorException):
            setting = self.client.bot_connection.get(
                resource_group_name=resource_group.name,
                resource_name=self.resource_name,
                connection_name=connection_resource_name
            )


    @unittest.skip("skip")
    def test_bot_connection_serviceproviders(self):
        service_provider_responses = self.client.bot_connection.list_service_providers()
        self.assertTrue(len(service_provider_responses.value) > 0)