File: disable_test_cli_mgmt_iothubprovisioningservices.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 (140 lines) | stat: -rw-r--r-- 6,343 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# coding: utf-8

#-------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#--------------------------------------------------------------------------


# TEST SCENARIO COVERAGE
# ----------------------
# Methods Total   : 18
# Methods Covered : 18
# Examples Total  : 18
# Examples Tested : 11
# Coverage %      : 61
# ----------------------

import unittest

import azure.mgmt.iothubprovisioningservices
from devtools_testutils import AzureMgmtTestCase, ResourceGroupPreparer

AZURE_LOCATION = 'eastus'

class MgmtIotDpsClientTest(AzureMgmtTestCase):

    def setUp(self):
        super(MgmtIotDpsClientTest, self).setUp()
        self.mgmt_client = self.create_mgmt_client(
            azure.mgmt.iothubprovisioningservices.IotDpsClient
        )
    
    @unittest.skip('hard to test')
    @ResourceGroupPreparer(location=AZURE_LOCATION)
    def test_iothubprovisioningservices(self, resource_group):

        SUBSCRIPTION_ID = self.settings.SUBSCRIPTION_ID
        TENANT_ID = self.settings.TENANT_ID
        RESOURCE_GROUP = resource_group.name
        PROVISIONING_SERVICE_NAME = "myProvisioningServiceRND"
        CERTIFICATE_NAME = "myCertificate"
        OPERATION_ID = "myOperationId"
        KEY_NAME = "myKey"

        # /IotDpsResource/put/DPSCreate[put]
        BODY = {
          "location": "East US",
          "type": "Microsoft.Devices/ProvisioningServices",
          "sku": {
            "name": "S1",
            "tier": "Standard",
            "capacity": "1"
          },
          "properties": {}
        }
        result = self.mgmt_client.iot_dps_resource.create_or_update(resource_group_name=RESOURCE_GROUP, provisioning_service_name=PROVISIONING_SERVICE_NAME, iot_dps_description=BODY)
        result = result.result()

        # /DpsCertificate/put/DPSCreateOrUpdateCertificate[put]
        BODY = {
          "certificate": "############################################"
        }
        # result = self.mgmt_client.dps_certificate.create_or_update(resource_group_name=RESOURCE_GROUP, provisioning_service_name=PROVISIONING_SERVICE_NAME, certificate_name=CERTIFICATE_NAME, certificate_description=BODY)

        # Certificates not tested yet
        # /DpsCertificate/get/DPSGetCertificate[get]
        # result = self.mgmt_client.dps_certificate.get(resource_group_name=RESOURCE_GROUP, provisioning_service_name=PROVISIONING_SERVICE_NAME, certificate_name=CERTIFICATE_NAME)

        # Certificates not tested yet
        # /IotDpsResource/get/DPSGetOperationResult[get]
        # result = self.mgmt_client.iot_dps_resource.get_operation_result(resource_group_name=RESOURCE_GROUP, provisioning_service_name=PROVISIONING_SERVICE_NAME, operation_id=OPERATION_ID, asyncinfo="1508265712453")

        # /DpsCertificate/get/DPSGetCertificates[get]
        result = self.mgmt_client.dps_certificate.list(resource_group_name=RESOURCE_GROUP, provisioning_service_name=PROVISIONING_SERVICE_NAME)

        # /IotDpsResource/get/DPSGetValidSku[get]
        result = self.mgmt_client.iot_dps_resource.list_valid_skus(resource_group_name=RESOURCE_GROUP, provisioning_service_name=PROVISIONING_SERVICE_NAME)

        # /IotDpsResource/get/DPSGet[get]
        result = self.mgmt_client.iot_dps_resource.get(resource_group_name=RESOURCE_GROUP, provisioning_service_name=PROVISIONING_SERVICE_NAME)

        # /IotDpsResource/get/DPSListByResourceGroup[get]
        result = self.mgmt_client.iot_dps_resource.list_by_resource_group(resource_group_name=RESOURCE_GROUP)

        # /IotDpsResource/get/DPSListBySubscription[get]
        result = self.mgmt_client.iot_dps_resource.list_by_subscription()

        # /Operations/get/DPSOperations[get]
        result = self.mgmt_client.operations.list()

        # Certificates not tested yet
        # /DpsCertificate/post/DPSGenerateVerificationCode[post]
        # result = self.mgmt_client.dps_certificate.generate_verification_code(resource_group_name=RESOURCE_GROUP, provisioning_service_name=PROVISIONING_SERVICE_NAME, certificate_name=CERTIFICATE_NAME)

        # Certificates not tested yet
        # /DpsCertificate/post/DPSVerifyCertificate[post]
        BODY = {
          "certificate": "#####################################"
        }
        # result = self.mgmt_client.dps_certificate.verify_certificate(resource_group_name=RESOURCE_GROUP, provisioning_service_name=PROVISIONING_SERVICE_NAME, certificate_name=CERTIFICATE_NAME, request=BODY)

        # Certificates not tested yet
        # /IotDpsResource/post/DPSGetKey[post]
        # result = self.mgmt_client.iot_dps_resource.list_keys_for_key_name(resource_group_name=RESOURCE_GROUP, provisioning_service_name=PROVISIONING_SERVICE_NAME, key_name=KEY_NAME)

        # /IotDpsResource/post/DPSListKeys[post]
        result = self.mgmt_client.iot_dps_resource.list_keys(resource_group_name=RESOURCE_GROUP, provisioning_service_name=PROVISIONING_SERVICE_NAME)

        # /IotDpsResource/patch/DPSPatch[patch]
        BODY = {
          "tags": {
            "foo": "bar"
          }
        }
        result = self.mgmt_client.iot_dps_resource.update(resource_group_name=RESOURCE_GROUP, provisioning_service_name=PROVISIONING_SERVICE_NAME, provisioning_service_tags=BODY)
        result = result.result()

        # /IotDpsResource/post/DPSCheckName[post]
        BODY = {
          "name": "test213123"
        }
        result = self.mgmt_client.iot_dps_resource.check_provisioning_service_name_availability(name="test213123")

        # Certificates not tested yet
        # /DpsCertificate/delete/DPSDeleteCertificate[delete]
        # result = self.mgmt_client.dps_certificate.delete(resource_group_name=RESOURCE_GROUP, provisioning_service_name=PROVISIONING_SERVICE_NAME, certificate_name=CERTIFICATE_NAME)

        # /IotDpsResource/delete/DPSDelete[delete]
        result = self.mgmt_client.iot_dps_resource.delete(resource_group_name=RESOURCE_GROUP, provisioning_service_name=PROVISIONING_SERVICE_NAME)

        try:
          result = result.result()
        except:
          print("poller failing")


#------------------------------------------------------------------------------
if __name__ == '__main__':
    unittest.main()