def test_app_service_environment_update(self, ase_client_factory_mock,
                                            resource_group_mock):
        ase_name = 'mock_ase_name'
        rg_name = 'mock_rg_name'

        ase_client = mock.MagicMock()
        ase_client_factory_mock.return_value = ase_client

        resource_group_mock.return_value = rg_name

        host_env = HostingEnvironmentProfile(id='id1')
        host_env.name = ase_name
        host_env.resource_group = rg_name
        host_env.worker_pools = []
        ase_client.get.return_value = host_env
        ase_client.list.return_value = [host_env]

        update_appserviceenvironment(self.mock_cmd,
                                     ase_name,
                                     front_end_scale_factor=10)

        # Assert create_or_update is called with correct properties
        assert_host_env = HostingEnvironmentProfile(id='id1')
        assert_host_env.name = ase_name
        assert_host_env.resource_group = rg_name
        assert_host_env.worker_pools = []
        assert_host_env.internal_load_balancing_mode = None
        assert_host_env.front_end_scale_factor = 10
        ase_client.create_or_update.assert_called_once_with(
            name=ase_name,
            resource_group_name=rg_name,
            hosting_environment_envelope=assert_host_env)
Example #2
0
    def test_app_service_environment_update(self, ase_client_factory_mock, resource_group_mock):
        ase_name = 'mock_ase_name'
        rg_name = 'mock_rg_name'

        ase_client = mock.MagicMock()
        ase_client_factory_mock.return_value = ase_client

        resource_group_mock.return_value = rg_name

        host_env = HostingEnvironmentProfile(id='/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/mock_rg_name/Microsoft.Web/hostingEnvironments/mock_ase_name')
        host_env.name = ase_name
        host_env.kind = 'ASEv2'
        ase_client.get.return_value = host_env
        ase_client.list.return_value = [host_env]

        update_appserviceenvironment(self.mock_cmd, ase_name, front_end_scale_factor=10)

        # Assert create_or_update is called with correct properties
        assert_host_env = HostingEnvironmentProfile(id='/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/mock_rg_name/Microsoft.Web/hostingEnvironments/mock_ase_name')
        assert_host_env.name = ase_name
        assert_host_env.kind = 'ASEv2'
        assert_host_env.internal_load_balancing_mode = None
        assert_host_env.front_end_scale_factor = 10
        ase_client.begin_create_or_update.assert_called_once_with(resource_group_name=rg_name, name=ase_name,
                                                                  hosting_environment_envelope=assert_host_env)
Example #3
0
    def test_app_service_environment_update_asev3(self, ase_client_factory_mock, resource_group_mock):
        ase_name = 'mock_ase_name'
        rg_name = 'mock_rg_name'

        ase_client = mock.MagicMock()
        ase_client_factory_mock.return_value = ase_client

        resource_group_mock.return_value = rg_name

        host_env = HostingEnvironmentProfile(id='/subscriptions/11111111-1111-1111-1111-111111111111/resourceGroups/mock_rg_name/Microsoft.Web/hostingEnvironments/mock_ase_name')
        host_env.name = ase_name
        host_env.kind = 'ASEv3'
        ase_client.get.return_value = host_env
        ase_client.list.return_value = [host_env]
        ase_networking_conf = AseV3NetworkingConfiguration(allow_new_private_endpoint_connections=False)
        ase_client.get_ase_v3_networking_configuration.return_value = ase_networking_conf

        update_appserviceenvironment(self.mock_cmd, ase_name, allow_new_private_endpoint_connections=True)

        # Assert create_or_update is called with correct properties
        ase_client.update_ase_networking_configuration.assert_called_once_with(resource_group_name=rg_name,
                                                                               name=ase_name,
                                                                               ase_networking_configuration=ase_networking_conf)