def __init__(self, method_name, config_file=None, recording_name=None, recording_processors=None, replay_processors=None, recording_patches=None, replay_patches=None): self.name_replacer = GeneralNameReplacer() super(ScenarioTest, self).__init__( method_name, config_file=config_file, recording_processors=recording_processors or [ SubscriptionRecordingProcessor(MOCKED_SUBSCRIPTION_ID), OAuthRequestResponsesFilter(), LargeRequestBodyProcessor(), LargeResponseBodyProcessor(), DeploymentNameReplacer(), RequestUrlNormalizer(), self.name_replacer, ], replay_processors=replay_processors or [ LargeResponseBodyReplacer(), DeploymentNameReplacer(), RequestUrlNormalizer(), ], recording_patches=recording_patches or [patch_main_exception_handler], replay_patches=replay_patches or [ patch_main_exception_handler, patch_time_sleep_api, patch_long_run_operation_delay, patch_load_cached_subscriptions, patch_retrieve_token_for_user, patch_progress_controller, ], recording_dir=find_recording_dir(inspect.getfile(self.__class__)), recording_name=recording_name )
def __init__(self, method_name, config_file=None, recording_name=None, recording_processors=None, replay_processors=None, recording_patches=None, replay_patches=None): self.cli_ctx = get_dummy_cli() self.name_replacer = GeneralNameReplacer() self.kwargs = {} self.test_guid_count = 0 default_recording_processors = [ SubscriptionRecordingProcessor(MOCKED_SUBSCRIPTION_ID), OAuthRequestResponsesFilter(), LargeRequestBodyProcessor(), LargeResponseBodyProcessor(), DeploymentNameReplacer(), RequestUrlNormalizer(), self.name_replacer, StorageAccountKeyReplacer() ] default_replay_processors = [ LargeResponseBodyReplacer(), DeploymentNameReplacer(), RequestUrlNormalizer(), ] default_recording_patches = [patch_main_exception_handler] default_replay_patches = [ patch_main_exception_handler, patch_time_sleep_api, patch_long_run_operation_delay, patch_load_cached_subscriptions, patch_retrieve_token_for_user, patch_progress_controller, ] def _merge_lists(base, patches): merged = list(base) if patches and not isinstance(patches, list): patches = [patches] if patches: merged = list(set(merged).union(set(patches))) return merged super(ScenarioTest, self).__init__( method_name, config_file=config_file, recording_processors=_merge_lists(default_recording_processors, recording_processors), replay_processors=_merge_lists(default_replay_processors, replay_processors), recording_patches=_merge_lists(default_recording_patches, recording_patches), replay_patches=_merge_lists(default_replay_patches, replay_patches), recording_dir=find_recording_dir(inspect.getfile(self.__class__)), recording_name=recording_name)
def __init__(self, method_name, **kwargs): self.scrubber = GeneralNameReplacer() super(StorageExampleTest, self).__init__(method_name, config_file=TEST_CONFIG, recording_processors=[ self.scrubber, SubscriptionRecordingProcessor(DUMMY_UUID), AccessTokenReplacer(), ], replay_patches=[ patch_long_run_operation_delay, ]) if self.is_live: constants_to_scrub = [(os.environ['AZURE_CLIENT_ID'], DUMMY_UUID), (os.environ['AZURE_CLIENT_SECRET'], DUMMY_SECRET), (os.environ['AZURE_TENANT_ID'], DUMMY_UUID), (STORAGE_ACCOUNT_NAME, DUMMY_STORAGE_NAME)] for key, replacement in constants_to_scrub: self.scrubber.register_name_pair(key, replacement) self.scrubber.register_name_pair(quote_plus(key), replacement)