From 71f5e530533b4b0ffc911a5efafd0634271e9a02 Mon Sep 17 00:00:00 2001 From: 00Kai0 Date: Thu, 18 Jun 2020 16:56:08 +0800 Subject: [PATCH] fix network in batch testcase --- .../azure-mgmt-batch/tests/test_mgmt_batch.py | 66 +++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/sdk/batch/azure-mgmt-batch/tests/test_mgmt_batch.py b/sdk/batch/azure-mgmt-batch/tests/test_mgmt_batch.py index 61775ef2023a..a32d5b4bf36f 100644 --- a/sdk/batch/azure-mgmt-batch/tests/test_mgmt_batch.py +++ b/sdk/batch/azure-mgmt-batch/tests/test_mgmt_batch.py @@ -35,10 +35,9 @@ def setUp(self): super(MgmtBatchTest, self).setUp() self.mgmt_batch_client = self.create_mgmt_client( azure.mgmt.batch.BatchManagementClient) - self.mgmt_keyvault_client = self.create_mgmt_client( - azure.mgmt.keyvault.KeyVaultManagementClient) - self.mgmt_network = self.create_mgmt_client( - azure.mgmt.network.NetworkManagementClient) + if self.is_live: + self.mgmt_network = self.create_mgmt_client( + azure.mgmt.network.NetworkManagementClient) def _get_account_name(self): return self.get_resource_name('batch')[-24:] @@ -424,35 +423,36 @@ def test_mgmt_batch_account_advanced(self, resource_group, location): resource_group_name=resource_group.name, account_name=batch_account_name, parameters=batch_account).result() - self.mgmt_network.virtual_networks.create_or_update( - resource_group_name=resource_group.name, - virtual_network_name=vnet_name, - parameters=self.mgmt_network.models().VirtualNetwork( - address_space=self.mgmt_network.models().AddressSpace( - address_prefixes=['10.0.0.0/16']), - location=location, - subnets=[ - self.mgmt_network.models().Subnet( - address_prefix='10.0.0.0/24', - name=subnet_name, - private_endpoint_network_policies='Disabled')]) - ).result() - self.mgmt_network.private_endpoints.create_or_update( - resource_group_name=resource_group.name, - private_endpoint_name=private_endpoint_name, - parameters=self.mgmt_network.models().PrivateEndpoint( - location=location, - subnet=self.mgmt_network.models().Subnet( - id=subnet_id - ), - manual_private_link_service_connections=[ - self.mgmt_network.models().PrivateLinkServiceConnection( - private_link_service_id=private_link_service_id, - group_ids=['batchAccount'], - name=private_connection_name - )] - ) - ).result() + if self.is_live: + self.mgmt_network.virtual_networks.begin_create_or_update( + resource_group_name=resource_group.name, + virtual_network_name=vnet_name, + parameters=self.mgmt_network.models().VirtualNetwork( + address_space=self.mgmt_network.models().AddressSpace( + address_prefixes=['10.0.0.0/16']), + location=location, + subnets=[ + self.mgmt_network.models().Subnet( + address_prefix='10.0.0.0/24', + name=subnet_name, + private_endpoint_network_policies='Disabled')]) + ).result() + self.mgmt_network.private_endpoints.begin_create_or_update( + resource_group_name=resource_group.name, + private_endpoint_name=private_endpoint_name, + parameters=self.mgmt_network.models().PrivateEndpoint( + location=location, + subnet=self.mgmt_network.models().Subnet( + id=subnet_id + ), + manual_private_link_service_connections=[ + self.mgmt_network.models().PrivateLinkServiceConnection( + private_link_service_id=private_link_service_id, + group_ids=['batchAccount'], + name=private_connection_name + )] + ) + ).result() private_links = self.mgmt_batch_client.private_link_resource.list_by_batch_account( resource_group_name=resource_group.name, account_name=batch_account_name)