-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
1,218 additions
and
0 deletions.
There are no files selected for viewing
1,147 changes: 1,147 additions & 0 deletions
1,147
...zext_storage_preview/tests/latest/recordings/test_storage_file_trailing_dot_scenario.yaml
Large diffs are not rendered by default.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
src/storage-preview/azext_storage_preview/tests/latest/test_storage_file_scenarios.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import os | ||
from azure.cli.testsdk import (ScenarioTest, ResourceGroupPreparer, StorageAccountPreparer, | ||
JMESPathCheck, NoneCheck, StringCheck, StringContainCheck, JMESPathCheckExists) | ||
from ..storage_test_util import StorageScenarioMixin | ||
from azure.cli.testsdk.scenario_tests import record_only | ||
|
||
|
||
class StorageFileShareScenarios(StorageScenarioMixin, ScenarioTest): | ||
@ResourceGroupPreparer() | ||
@StorageAccountPreparer(location='EastUS2') | ||
def test_storage_file_trailing_dot_scenario(self, resource_group, storage_account): | ||
account_info = self.get_account_info(resource_group, storage_account) | ||
s1 = self.create_share(account_info) | ||
|
||
self._validate_file_trailing_dot_scenario(account_info, s1) | ||
self._validate_directory_trailing_dot_scenario(account_info, s1) | ||
|
||
self.storage_cmd('storage share delete -n {}', account_info, s1) \ | ||
.assert_with_checks(JMESPathCheck('deleted', True)) | ||
|
||
def _validate_directory_trailing_dot_scenario(self, account_info, share): | ||
directory = self.create_random_name('dir', 16) | ||
directory = directory+'..' | ||
self.storage_cmd('storage directory create --share-name {} --name {} --fail-on-exist', | ||
account_info, share, directory) \ | ||
.assert_with_checks(JMESPathCheck('created', True)) | ||
self.storage_cmd('storage directory list -s {}', account_info, share) \ | ||
.assert_with_checks(JMESPathCheck('length(@)', 1)) | ||
self.storage_cmd('storage directory show --share-name {} -n {}', | ||
account_info, share, directory) \ | ||
.assert_with_checks(JMESPathCheck('name', directory)) | ||
|
||
self.storage_cmd('storage directory create --share-name {} --name {} --fail-on-exist --disallow-trailing-dot', | ||
account_info, share, directory) \ | ||
.assert_with_checks(JMESPathCheck('created', True)) | ||
self.storage_cmd('storage directory list -s {}', account_info, share) \ | ||
.assert_with_checks(JMESPathCheck('length(@)', 2)) | ||
self.storage_cmd('storage directory show --share-name {} -n {} --disallow-trailing-dot', | ||
account_info, share, directory[:-2]) \ | ||
.assert_with_checks(JMESPathCheck('name', directory[:-2])) | ||
|
||
def _validate_file_trailing_dot_scenario(self, account_info, share): | ||
source_file = self.create_temp_file(128, full_random=False) | ||
dest_file = self.create_temp_file(1) | ||
filename = "sample_file.bin..." | ||
|
||
self.storage_cmd('storage file upload --share-name {} --source "{}" -p {}', account_info, | ||
share, source_file, filename) | ||
self.storage_cmd('storage file exists -s {} -p {}', account_info, share, filename) \ | ||
.assert_with_checks(JMESPathCheck('exists', True)) | ||
|
||
if os.path.isfile(dest_file): | ||
os.remove(dest_file) | ||
|
||
self.storage_cmd('storage file download --share-name {} -p "{}" --dest "{}"', account_info, | ||
share, filename, dest_file) | ||
|
||
self.assertTrue(os.path.isfile(dest_file)) | ||
self.assertEqual(os.stat(dest_file).st_size, 128 * 1024) | ||
|
||
with self.assertRaises(Exception): | ||
self.storage_cmd('storage file download --share-name {} -p "{}" --dest "{}" --disallow-trailing-dot', | ||
account_info, share, filename, dest_file) | ||
|
||
self.storage_cmd('storage file delete -s {} -p {}', account_info, share, filename) | ||
self.storage_cmd('storage file exists -s {} -p {}', account_info, share, filename) \ | ||
.assert_with_checks(JMESPathCheck('exists', False)) | ||
self.storage_cmd('storage file upload --share-name {} --source "{}" -p {} --disallow-trailing-dot', account_info, | ||
share, source_file, filename) | ||
self.storage_cmd('storage file exists -s {} -p {} --disallow-trailing-dot', account_info, share, filename) \ | ||
.assert_with_checks(JMESPathCheck('exists', True)) |