Skip to content

Commit

Permalink
Revert "[Batch] Upgrade api-version to v2021-06-01 (Azure#19100)"
Browse files Browse the repository at this point in the history
This reverts commit ed4e903.
  • Loading branch information
Charlie McBride authored and Charlie McBride committed Aug 15, 2021
1 parent 0df7c06 commit 8aa3f09
Show file tree
Hide file tree
Showing 180 changed files with 8,405 additions and 18,295 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 unittest.mock import patch
from 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
from unittest import mock
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
from unittest import mock
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
from unittest import mock
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('2021-06-01-preview', {
ResourceType.MGMT_CONTAINERREGISTRY: SDKProfile('2020-11-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
from unittest import mock
import unittest.mock as 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
from unittest import mock
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

from unittest import mock
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
from unittest import mock
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):
from unittest import mock
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
from unittest import mock
import mock
import unittest
from collections import namedtuple

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

from unittest import mock
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
from unittest import mock
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
from unittest import mock
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.
# --------------------------------------------------------------------------------------------

from unittest import mock
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.
# --------------------------------------------------------------------------------------------

from unittest import mock
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
from unittest import mock
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
from unittest import mock
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):
from unittest import mock
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
from unittest import mock
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[0][1]
request = send_mock.call_args.args[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[1]["verify"], not should_disable_connection_verify())
self.assertEqual(send_mock.call_args.kwargs["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[0][1]
request = send_mock.call_args.args[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[0][1]
request = send_mock.call_args.args[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[0][1]
request = send_mock.call_args.args[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[0][1]
request = send_mock.call_args.args[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[0][1]
request = send_mock.call_args.args[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[0][1]
request = send_mock.call_args.args[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[0][1]
request = send_mock.call_args.args[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[0][1]
request = send_mock.call_args.args[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[0][1]
request = send_mock.call_args.args[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[0][1]
request = send_mock.call_args.args[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[0][1]
request = send_mock.call_args.args[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[0][0])
self.assertIn(err_msg, mock_logger_error.call_args.args[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[0][0])
self.assertIn(mock_cloud_error.args[0], mock_logger_error.call_args.args[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[0][0])
self.assertIn(err_code, mock_logger_error.call_args[0][0])
self.assertIn(err_msg, mock_logger_error.call_args.args[0])
self.assertIn(err_code, mock_logger_error.call_args.args[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[0][0])
self.assertIn(expected_message, mock_logger_error.call_args.args[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.assertIs(str(mock_http_error), mock_logger_error.call_args[0][0])
self.assertIn(str(mock.call(mock_http_error).args[0]), mock_logger_error.call_args.args[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_http_error), mock_logger_error.call_args[0][0])
self.assertIn(str(mock.call(mock_http_error).args[0]), mock_logger_error.call_args.args[0])
self.assertEqual(ex_result, 1)

@staticmethod
Expand Down
7 changes: 7 additions & 0 deletions src/azure-cli-core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@
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 @@ -84,5 +87,9 @@
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 8aa3f09

Please sign in to comment.