Skip to content

Commit

Permalink
[Batch] Upgrade api-version to v2021-06-01 (#19100)
Browse files Browse the repository at this point in the history
* Improve nodepool help text for OS Disk options (#19073)

* {AKS} Refactor acs module: add test cases for sub-command `create` (#19026)

* add test for autoscaler

* add test for loadbalancer

* add test for node public ip

* add test for network cidr

* update create default test

* add test for create attach acr

* add AKSCustomRoleBasedServicePrincipalPreparer

* update test ingress appgw

* add test case for outbound type udr

* add test for node_osdisk_diskencryptionset

* add test for enable-encryption-at-host, enable-azure-rbac, disable-rbac and dns-service-ip

* add test for workspace-resource-id

* add recordings

* update recordings

* [SQL] az sql mi update: Add --subnet and --vnet-name parameters to support the cross subnet update SLO (#18886)

* Update sql track2

* Update commands.py

update begin_delete

* update setter_name to pass sdk validation

* replace_all_delete

* pass az self-check

* update recording tests

* fix all begin_xyz issue

* run test to unblock some issues

* pass SqlServerMSSupportScenarioTest

* change region to pass tests

* pass LTR test

* add recorded tests for MI

* update db_rename parameters

* pass db management tests

* address aad tests

* pass sql server aad

* revert azure-mgmt-netapp version change

* record test after rebase

* add three passed tests

* modify short term policy

* complete another three tests

* pass tde test

* pass two more tests

* Update custom.py

* pass two more tests

* pass classification test

* pass long and short backup

* update test file to match new config

* pass server and db security tests

* record test_sql_db_sensitivity_classifications again

* update MI tests

* pass MI tests

* pass tests

* modify instance_pool_test

* Iteration 1:
- Adding support for cross subnet update SLO

* Iteration 2:
- Removing the change from History.rst file

* Iteration 3:
- Fixing merge errors

* Iteration 4:
- Removing merge errors

* Iteration 5:
- Removing merge errors

* Iteration 6:
- Fixed merge errors

* Iteration 7:
- Fix merge errors

* Iteration 7:
- Fixed CLI style issue - removed two trailing spaces
- Fixed CLI linter issue - fixed the cross-subnet update slo command in _help.py

Co-authored-by: Ji Wang <wangjiprc@gmail.com>
Co-authored-by: Nemanja <nemanjas@microsoft.ccom>

* [ACR] `acr create/update`: Add new parameter `--allow-exports` to support export (#19065)

* Update azure-mgmt-containerregistry from 8.0.0 to 8.1.0. Add support for export disable.

* Add acr export policy tests

style fix

* re-record acr dependent tests

* style: disable too many locals

* fix style issue

Co-authored-by: Tosin Adewale <oluwatosin.adewale@microsoft.com>

* Fix linter failures (#19116)

* {Packaging} Drop `mock` library (#19024)

* Upgrades Batch SDKs

* Python Data Plane SDK: 11.0.0
* Python Management Plane SDK: 16.0.0
* Fixes data plane tests

* New `outbound-endpoints` and `list-skus` commands

* `az batch account outbound-endpoints`
* `az batch location list-skus`

* Updates tests and session recordings

* Fixes help linting

Co-authored-by: Ismayil <ismayilmirzeli@gmail.com>
Co-authored-by: FumingZhang <81607949+FumingZhang@users.noreply.github.com>
Co-authored-by: v-nestan <58415436+v-nestan@users.noreply.github.com>
Co-authored-by: Ji Wang <wangjiprc@gmail.com>
Co-authored-by: Nemanja <nemanjas@microsoft.ccom>
Co-authored-by: Tosin Adewale <oladewal@microsoft.com>
Co-authored-by: Tosin Adewale <oluwatosin.adewale@microsoft.com>
Co-authored-by: jiasli <4003950+jiasli@users.noreply.github.com>
Co-authored-by: Yishi Wang <yishiwang@microsoft.com>
Co-authored-by: David Watrous <509299+dpwatrous@users.noreply.github.com>
Co-authored-by: Shiran Pasternak <shiran.pasternak@microsoft.com>
  • Loading branch information
12 people committed Aug 7, 2021
1 parent 71456b1 commit ed4e903
Show file tree
Hide file tree
Showing 180 changed files with 18,295 additions and 8,405 deletions.
6 changes: 3 additions & 3 deletions doc/sphinx/azhelpgen/azhelpgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import argparse
import json
from mock import patch
from unittest.mock import patch
from os.path import expanduser
from docutils import nodes
from docutils.statemachine import ViewList
Expand Down Expand Up @@ -51,7 +51,7 @@ def make_rst(self):
if help_file.deprecate_info:
yield '{}:deprecated: {}'.format(INDENT, help_file.deprecate_info._get_message(help_file.deprecate_info))
if not is_command:
top_group_name = help_file.command.split()[0] if help_file.command else 'az'
top_group_name = help_file.command.split()[0] if help_file.command else 'az'
yield '{}:docsource: {}'.format(INDENT, doc_source_map[top_group_name] if top_group_name in doc_source_map else '')
else:
top_command_name = help_file.command.split()[0] if help_file.command else ''
Expand All @@ -61,7 +61,7 @@ def make_rst(self):

if is_command and help_file.parameters:
group_registry = ArgumentGroupRegistry(
[p.group_name for p in help_file.parameters if p.group_name])
[p.group_name for p in help_file.parameters if p.group_name])

for arg in sorted(help_file.parameters,
key=lambda p: group_registry.get_group_priority(p.group_name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import unittest
import tempfile
import shutil
import mock
from unittest import mock


def get_test_data_file(filename):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import unittest
import shutil
import hashlib
import mock
from unittest import mock
import sys

from azure.cli.core.util import CLIError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
import os
import mock
from unittest import mock
import unittest
from requests.exceptions import ConnectionError, HTTPError
from azure.cli.core.util import CLIError
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/profiles/_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def default_api_version(self):
'role_definitions': '2018-01-01-preview',
'provider_operations_metadata': '2018-01-01-preview'
}),
ResourceType.MGMT_CONTAINERREGISTRY: SDKProfile('2020-11-01-preview', {
ResourceType.MGMT_CONTAINERREGISTRY: SDKProfile('2021-06-01-preview', {
'agent_pools': '2019-06-01-preview',
'tasks': '2019-06-01-preview',
'task_runs': '2019-06-01-preview',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# pylint: disable=line-too-long
import datetime
import unittest
import unittest.mock as mock
from unittest import mock
from unittest.mock import MagicMock

from azure.cli.core.adal_authentication import AdalAuthentication, _try_scopes_to_resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# --------------------------------------------------------------------------------------------

import unittest
import mock
from unittest import mock

from azure.cli.core.profiles import (ResourceType, PROFILE_TYPE, CustomResourceType,
get_api_version, supported_api_version, register_resource_type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import unittest

import mock
from unittest import mock
import os
import tempfile

Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/tests/test_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import tempfile
import unittest
import mock
from unittest import mock
import multiprocessing
import configparser

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def test_get_error_type(self):
self.assertEqual(result_error_type, expected_error_type.value)

def test_get_parameter_mappings(self):
import mock
from unittest import mock
from azure.cli.core import AzCommandsLoader
from azure.cli.core.mock import DummyCli
from azure.cli.core.command_recommender import get_parameter_mappings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import sys
import logging
import mock
from unittest import mock
import unittest
from collections import namedtuple

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
import os
import logging
import unittest
try:
from unittest.mock import MagicMock
except ImportError:
from mock import MagicMock
from unittest.mock import MagicMock

import azure.cli.core._debug as _debug
import azure.cli.core.util as cli_util
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/tests/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import shutil
import zipfile

import mock
from unittest import mock

from azure.cli.core.extension import (get_extensions, build_extension_path, extension_exists,
get_extension, get_extension_names, get_extension_modname, ext_compat_with_cli,
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/tests/test_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from inspect import getmembers as inspect_getmembers

import unittest
import mock
from unittest import mock
import tempfile

from knack.help import GroupHelpFile, HelpAuthoringException
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/tests/test_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import os
import shutil
from knack.util import CLIError
import mock
from unittest import mock

from azure.cli.core.keys import generate_ssh_keys

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import mock
from unittest import mock
import unittest

from azure.cli.core.local_context import AzCLILocalContext, ALL
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

import mock
from unittest import mock
import unittest
import difflib
from io import StringIO
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/tests/test_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import sys
import unittest
import mock
from unittest import mock
import re

from copy import deepcopy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import sys
import unittest
import mock
from unittest import mock
import re

from copy import deepcopy
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli-core/azure/cli/core/tests/test_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def test_extract_parameters_correctly(self):
self.assertEqual(['-g', '--name', '-d', '--debug'], AzCliCommandInvoker._extract_parameter_names(args))

def test_cloud_forbid_telemetry(self):
import mock
from unittest import mock
import azure.cli.core.telemetry as telemetry
from azure.cli.core.mock import DummyCli
from knack.completion import ARGCOMPLETE_ENV_NAME
Expand Down
42 changes: 21 additions & 21 deletions src/azure-cli-core/azure/cli/core/tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
import sys
import unittest
import mock
from unittest import mock
import tempfile
import json

Expand Down Expand Up @@ -270,20 +270,20 @@ def test_send_raw_requests(self, send_mock, get_raw_token_mock):
generated_client_request_id_name=None)

get_raw_token_mock.assert_not_called()
request = send_mock.call_args.args[1]
request = send_mock.call_args[0][1]
self.assertEqual(request.method, 'PUT')
self.assertEqual(request.url, 'https://myaccount.blob.core.windows.net/mycontainer/myblob?timeout=30&sv=2019-02-02&srt=s&ss=bf')
self.assertEqual(request.body, '{"b1": "v1"}')
# Verify no Authorization header
self.assertDictEqual(dict(request.headers), expected_header)
self.assertEqual(send_mock.call_args.kwargs["verify"], not should_disable_connection_verify())
self.assertEqual(send_mock.call_args[1]["verify"], not should_disable_connection_verify())

# Test Authorization header is skipped
send_raw_request(cli_ctx, 'GET', full_arm_rest_url, body=test_body, skip_authorization_header=True,
generated_client_request_id_name=None)

get_raw_token_mock.assert_not_called()
request = send_mock.call_args.args[1]
request = send_mock.call_args[0][1]
self.assertDictEqual(dict(request.headers), expected_header)

# Test Authorization header is already provided
Expand All @@ -292,7 +292,7 @@ def test_send_raw_requests(self, send_mock, get_raw_token_mock):
generated_client_request_id_name=None)

get_raw_token_mock.assert_not_called()
request = send_mock.call_args.args[1]
request = send_mock.call_args[0][1]
self.assertDictEqual(dict(request.headers), {**expected_header, 'Authorization': 'Basic ABCDE'})

# Test Authorization header is auto appended
Expand All @@ -301,7 +301,7 @@ def test_send_raw_requests(self, send_mock, get_raw_token_mock):
generated_client_request_id_name=None)

get_raw_token_mock.assert_called_with(mock.ANY, test_arm_active_directory_resource_id, subscription=subscription_id)
request = send_mock.call_args.args[1]
request = send_mock.call_args[0][1]
self.assertDictEqual(dict(request.headers), expected_header_with_auth)

# Test ARM Subscriptions - List
Expand All @@ -311,7 +311,7 @@ def test_send_raw_requests(self, send_mock, get_raw_token_mock):
generated_client_request_id_name=None)

get_raw_token_mock.assert_called_with(mock.ANY, test_arm_active_directory_resource_id)
request = send_mock.call_args.args[1]
request = send_mock.call_args[0][1]
self.assertEqual(request.url, test_arm_endpoint.rstrip('/') + '/subscriptions?api-version=2020-01-01')
self.assertDictEqual(dict(request.headers), expected_header_with_auth)

Expand All @@ -322,7 +322,7 @@ def test_send_raw_requests(self, send_mock, get_raw_token_mock):
generated_client_request_id_name=None)

get_raw_token_mock.assert_called_with(mock.ANY, test_arm_active_directory_resource_id)
request = send_mock.call_args.args[1]
request = send_mock.call_args[0][1]
self.assertEqual(request.url, test_arm_endpoint.rstrip('/') + '/tenants?api-version=2020-01-01')
self.assertDictEqual(dict(request.headers), expected_header_with_auth)

Expand All @@ -332,7 +332,7 @@ def test_send_raw_requests(self, send_mock, get_raw_token_mock):
generated_client_request_id_name=None)

get_raw_token_mock.assert_called_with(mock.ANY, test_arm_active_directory_resource_id, subscription=subscription_id)
request = send_mock.call_args.args[1]
request = send_mock.call_args[0][1]
self.assertEqual(request.url, full_arm_rest_url)
self.assertDictEqual(dict(request.headers), expected_header_with_auth)

Expand All @@ -341,7 +341,7 @@ def test_send_raw_requests(self, send_mock, get_raw_token_mock):
send_raw_request(cli_ctx, 'GET', full_arm_rest_url)

get_raw_token_mock.assert_called_with(mock.ANY, test_arm_active_directory_resource_id, subscription=subscription_id)
request = send_mock.call_args.args[1]
request = send_mock.call_args[0][1]
self.assertEqual(request.url, full_arm_rest_url)

# Test full ARM URL with port
Expand All @@ -351,7 +351,7 @@ def test_send_raw_requests(self, send_mock, get_raw_token_mock):
send_raw_request(cli_ctx, 'GET', full_arm_rest_url_with_port)

get_raw_token_mock.assert_called_with(mock.ANY, test_arm_active_directory_resource_id, subscription=subscription_id)
request = send_mock.call_args.args[1]
request = send_mock.call_args[0][1]
self.assertEqual(request.url, 'https://management.azure.com:443/subscriptions/00000001-0000-0000-0000-000000000000/resourcegroups/02?api-version=2019-07-01')

# Test non-ARM APIs
Expand All @@ -360,15 +360,15 @@ def test_send_raw_requests(self, send_mock, get_raw_token_mock):
url = 'https://graph.windows.net/00000002-0000-0000-0000-000000000000/applications/00000003-0000-0000-0000-000000000000?api-version=1.6'
send_raw_request(cli_ctx, 'PATCH', url, body=test_body, generated_client_request_id_name=None)
get_raw_token_mock.assert_called_with(mock.ANY, 'https://graph.windows.net/')
request = send_mock.call_args.args[1]
request = send_mock.call_args[0][1]
self.assertEqual(request.method, 'PATCH')
self.assertEqual(request.url, url)

# Test MS Graph API https://graph.microsoft.com/beta/appRoleAssignments/01
url = 'https://graph.microsoft.com/beta/appRoleAssignments/01'
send_raw_request(cli_ctx, 'PATCH', url, body=test_body, generated_client_request_id_name=None)
get_raw_token_mock.assert_called_with(mock.ANY, 'https://graph.microsoft.com/')
request = send_mock.call_args.args[1]
request = send_mock.call_args[0][1]
self.assertEqual(request.method, 'PATCH')
self.assertEqual(request.url, url)

Expand All @@ -377,7 +377,7 @@ def test_send_raw_requests(self, send_mock, get_raw_token_mock):
send_raw_request(cli_ctx, 'GET', full_arm_rest_url, headers={'user-agent=ARG-UA'})

get_raw_token_mock.assert_called_with(mock.ANY, test_arm_active_directory_resource_id, subscription=subscription_id)
request = send_mock.call_args.args[1]
request = send_mock.call_args[0][1]
self.assertEqual(request.headers['User-Agent'], get_az_rest_user_agent() + ' env-ua ARG-UA')

def test_scopes_to_resource(self):
Expand Down Expand Up @@ -496,7 +496,7 @@ def test_handle_exception_clierror(self, mock_logger_error):

# test behavior
self.assertTrue(mock_logger_error.called)
self.assertIn(err_msg, mock_logger_error.call_args.args[0])
self.assertIn(err_msg, mock_logger_error.call_args[0][0])
self.assertEqual(ex_result, 1)

@mock.patch('azure.cli.core.azclierror.logger.error', autospec=True)
Expand All @@ -514,7 +514,7 @@ def test_handle_exception_clouderror(self, mock_logger_error):

# test behavior
self.assertTrue(mock_logger_error.called)
self.assertIn(mock_cloud_error.args[0], mock_logger_error.call_args.args[0])
self.assertIn(mock_cloud_error.args[0], mock_logger_error.call_args[0][0])
self.assertEqual(ex_result, 1)

@mock.patch('azure.cli.core.azclierror.logger.error', autospec=True)
Expand All @@ -531,8 +531,8 @@ def test_handle_exception_httpoperationerror_typical_response_error(self, mock_l

# test behavior
self.assertTrue(mock_logger_error.called)
self.assertIn(err_msg, mock_logger_error.call_args.args[0])
self.assertIn(err_code, mock_logger_error.call_args.args[0])
self.assertIn(err_msg, mock_logger_error.call_args[0][0])
self.assertIn(err_code, mock_logger_error.call_args[0][0])
self.assertEqual(ex_result, 1)

@mock.patch('azure.cli.core.azclierror.logger.error', autospec=True)
Expand All @@ -552,7 +552,7 @@ def test_handle_exception_httpoperationerror_error_key_has_string_value(self, mo

# test behavior
self.assertTrue(mock_logger_error.called)
self.assertIn(expected_message, mock_logger_error.call_args.args[0])
self.assertIn(expected_message, mock_logger_error.call_args[0][0])
self.assertEqual(ex_result, 1)

@mock.patch('azure.cli.core.azclierror.logger.error', autospec=True)
Expand All @@ -570,7 +570,7 @@ def test_handle_exception_httpoperationerror_no_error_key(self, mock_logger_erro

# test behavior
self.assertTrue(mock_logger_error.called)
self.assertIn(str(mock.call(mock_http_error).args[0]), mock_logger_error.call_args.args[0])
self.assertIs(str(mock_http_error), mock_logger_error.call_args[0][0])
self.assertEqual(ex_result, 1)

@mock.patch('azure.cli.core.azclierror.logger.error', autospec=True)
Expand All @@ -587,7 +587,7 @@ def test_handle_exception_httpoperationerror_no_response_text(self, mock_logger_

# test behavior
self.assertTrue(mock_logger_error.called)
self.assertIn(str(mock.call(mock_http_error).args[0]), mock_logger_error.call_args.args[0])
self.assertIn(str(mock_http_error), mock_logger_error.call_args[0][0])
self.assertEqual(ex_result, 1)

@staticmethod
Expand Down
7 changes: 0 additions & 7 deletions src/azure-cli-core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@
if not sys.platform.startswith('cygwin'):
DEPENDENCIES.append('psutil~=5.8')

TESTS_REQUIRE = [
'mock'
]

with open('README.rst', 'r', encoding='utf-8') as f:
README = f.read()
Expand All @@ -87,9 +84,5 @@
packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests", "azure", "azure.cli"]),
install_requires=DEPENDENCIES,
python_requires='>=3.6.0',
extras_require={
"test": TESTS_REQUIRE,
},
tests_require=TESTS_REQUIRE,
package_data={'azure.cli.core': ['auth_landing_pages/*.html']}
)
Loading

0 comments on commit ed4e903

Please sign in to comment.