Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/azure-cli-testsdk/azure/cli/testsdk/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
from azure_devtools.scenario_tests import (IntegrationTestBase, ReplayableTest, SubscriptionRecordingProcessor,
OAuthRequestResponsesFilter, LargeRequestBodyProcessor,
LargeResponseBodyProcessor, LargeResponseBodyReplacer, RequestUrlNormalizer,
live_only, DeploymentNameReplacer, create_random_name)
live_only, DeploymentNameReplacer, patch_time_sleep_api, create_random_name)

from azure_devtools.scenario_tests.const import MOCKED_SUBSCRIPTION_ID, ENV_SKIP_ASSERT

from .patches import (patch_load_cached_subscriptions, patch_main_exception_handler,
patch_retrieve_token_for_user, patch_long_run_operation_delay,
patch_progress_controller, patch_get_current_system_username, patch_time_sleep_api)
patch_progress_controller, patch_get_current_system_username)
from .exceptions import CliExecutionError
from .utilities import find_recording_dir, StorageAccountKeyReplacer, GraphClientPasswordReplacer, GeneralNameReplacer
from .reverse_dependency import get_dummy_cli
Expand Down
28 changes: 4 additions & 24 deletions src/azure-cli-testsdk/azure/cli/testsdk/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,14 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure_devtools.scenario_tests import mock_in_unit_test
from azure_devtools.scenario_tests.const import MOCKED_SUBSCRIPTION_ID, MOCKED_TENANT_ID
from azure_devtools.scenario_tests.exceptions import AzureTestError

from .exceptions import CliExecutionError

MOCKED_USER_NAME = '[email protected]'


def patch_time_sleep_api(unit_test):
def _time_sleep_skip(*_):
return

mock_in_unit_test(unit_test, 'time.sleep', _time_sleep_skip)


def patch_progress_controller(unit_test):
def _mock_pass(*args, **kwargs): # pylint: disable=unused-argument
pass
Expand Down Expand Up @@ -101,19 +94,6 @@ def _get_current_system_username(*args, **kwargs): # pylint: disable=unused-arg
from .utilities import create_random_name
return create_random_name(prefix='example_')

mock_in_unit_test(unit_test, 'azure.cli.core.local_context._get_current_system_username', _get_current_system_username)


def mock_in_unit_test(unit_test, target, replacement):
try:
import unittest.mock as mock
except ImportError:
import mock
import unittest

if not isinstance(unit_test, unittest.TestCase):
raise AzureTestError('Patches can be only called from a unit test')

mp = mock.patch(target, replacement)
mp.__enter__()
unit_test.addCleanup(mp.__exit__, None, None, None)
mock_in_unit_test(unit_test,
'azure.cli.core.local_context._get_current_system_username',
_get_current_system_username)
2 changes: 1 addition & 1 deletion src/azure-cli-testsdk/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
'jmespath',
'mock',
'vcrpy>=1.10.3',
'azure-devtools~=1.0.0'
'azure-devtools==1.2.0'
]

with open('README.rst', 'r', encoding='utf-8') as f:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure_devtools.scenario_tests import RecordingProcessor
from azure.cli.testsdk.patches import mock_in_unit_test
from azure_devtools.scenario_tests import RecordingProcessor, mock_in_unit_test


MOCK_JOB_ID = '00000000-0000-0000-0000-000000000000'
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ azure-cli-telemetry==1.0.4
azure-common==1.1.22
azure-cosmos==3.1.0
azure-datalake-store==0.0.48
azure-devtools==1.0.0
azure-devtools==1.2.0
azure-functions-devops-build==0.0.22
azure-graphrbac==0.60.0
azure-keyvault==1.1.0
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ azure-cli-telemetry==1.0.4
azure-common==1.1.22
azure-cosmos==3.1.0
azure-datalake-store==0.0.48
azure-devtools==1.0.0
azure-devtools==1.2.0
azure-functions-devops-build==0.0.22
azure-graphrbac==0.60.0
azure-keyvault==1.1.0
Expand Down
1 change: 1 addition & 0 deletions src/azure-cli/requirements.py3.windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ azure-cli-telemetry==1.0.4
azure-common==1.1.22
azure-cosmos==3.1.0
azure-datalake-store==0.0.48
azure-devtools==1.2.0
azure-functions-devops-build==0.0.22
azure-graphrbac==0.60.0
azure-keyvault==1.1.0
Expand Down