How to use reset_path method in tempest

Best Python code snippet using tempest_python

test_azure_3_copy.py

Source:test_azure_3_copy.py Github

copy

Full Screen

1from azure_storage.methods import \2 move_prep, \3 delete_container4from azure_storage.azure_move import \5 AzureContainerMove, \6 AzureMove7from azure_storage.azure_copy import \8 cli, \9 container_copy, \10 file_copy, \11 folder_copy12from unittest.mock import patch13import argparse14import pytest15import azure16import os171819@pytest.fixture(name='variables', scope='module')20def setup():21 class Variables:22 def __init__(self):23 self.account_name = 'carlingst01'24 self.container_name = '00000container'25 self.target_container = '0000000000container'26 self.storage_tier = 'Hot'2728 return Variables()293031def run_copy_prep(variables):32 variables.container_name, variables.target_container, variables.blob_service_client, \33 variables.source_container_client, variables.target_container_client = move_prep(34 account_name=variables.account_name,35 container_name=variables.container_name,36 target_container=variables.target_container37 )383940def test_copy_prep(variables):41 run_copy_prep(variables=variables)42 assert type(variables.source_container_client) is azure.storage.blob._container_client.ContainerClient434445def test_copy_prep_target_exists(variables):46 run_copy_prep(variables=variables)47 assert type(variables.target_container_client) is azure.storage.blob._container_client.ContainerClient484950@pytest.mark.parametrize('file_name,path,rename',51 [('file_1.txt', '', 'file_1_copy.txt'),52 ('file_1', '', 'file_1_copy'),53 ('file_1.gz', '', 'file_1_copy.gz'),54 ('file_2.txt', 'nested', 'file_2_copy.txt'),55 ('nested_folder/folder_test_1.txt', 'folder_test_1_copy.txt', 'folder_test_1_copy.txt'),56 ('nested_folder/nested_folder_2/nested_folder_test_1.txt', 'ABC',57 'nested_folder_test_1_copy.txt'),58 ('nested_folder/nested_folder_2/nested_folder_test_1.txt', 'ABC/123',59 'nested_folder_test_1_copy.txt'),60 ('nested/file_2.txt', 'nested_folder_2', 'file_2_copy.txt')])61def test_copy_file(variables, file_name, path, rename):62 AzureMove.move_file(63 source_container_client=variables.source_container_client,64 object_name=file_name,65 blob_service_client=variables.blob_service_client,66 container_name=variables.container_name,67 target_container=variables.target_container,68 path=path,69 storage_tier=variables.storage_tier,70 rename=rename71 )72 blobs = variables.target_container_client.list_blobs()73 assert os.path.join(path, os.path.basename(rename)) in [blob.name for blob in blobs]747576@pytest.mark.parametrize('file_name,path,rename',77 [('file_7.txt', '', 'file_7_copy.txt'),78 ('nonexistent/file_2.txt', 'nested_2', 'file_2_copy.txt'),79 ('nested/file_3.txt', 'nested_folder_2', 'file_3_copy.txt')])80def test_copy_file_invalid(variables, file_name, path, rename):81 with pytest.raises(SystemExit):82 AzureMove.move_file(83 source_container_client=variables.source_container_client,84 object_name=file_name,85 blob_service_client=variables.blob_service_client,86 container_name=variables.container_name,87 target_container=variables.target_container,88 path=path,89 storage_tier=variables.storage_tier,90 rename=rename91 )929394@pytest.mark.parametrize('file_name,path,rename',95 [('nested_file_1.txt', '', 'nested_file_1_copy.txt'),96 ('nested_folder/nested_file_2.txt', 'nested', 'nested_file_2_copy.txt')])97def test_copy_file_cool(variables, file_name, path, rename):98 storage_tier = 'Cool'99 AzureMove.move_file(100 source_container_client=variables.source_container_client,101 object_name=file_name,102 blob_service_client=variables.blob_service_client,103 container_name=variables.container_name,104 target_container=variables.target_container,105 path=path,106 storage_tier=storage_tier,107 rename=rename108 )109 blobs = variables.target_container_client.list_blobs()110 for blob in blobs:111 if blob.name == os.path.join(path, rename):112 assert blob.blob_tier == storage_tier113114115@pytest.mark.parametrize('folder_name,path,check_file',116 [('single_nested', '', 'triple_nested_file.txt'),117 ('nested_folder/nested_folder_2', 'nested_folder_3', 'nested_folder_test_1.txt'),118 ('nested_folder/nested_folder_2', '', 'nested_folder_test_1.txt')])119def test_copy_folder(variables, folder_name, path, check_file):120 AzureMove.move_folder(121 source_container_client=variables.source_container_client,122 object_name=folder_name,123 blob_service_client=variables.blob_service_client,124 container_name=variables.container_name,125 target_container=variables.target_container,126 path=path,127 storage_tier=variables.storage_tier,128 category='folder',129 )130 blobs = variables.target_container_client.list_blobs()131 assert os.path.join(path, os.path.basename(check_file)) in [blob.name for blob in blobs]132 original_blobs = variables.source_container_client.list_blobs()133 assert folder_name in [os.path.dirname(blob.name) for blob in original_blobs]134135136@pytest.mark.parametrize('folder_name,path,check_file',137 [('cool/nested_folder_2', '', 'nested_folder_test_1.txt'),138 ('cool_nested_folder_5', 'hot', 'nested_folder_test_1.txt')])139def test_copy_folder_cool(variables, folder_name, path, check_file):140 AzureMove.move_folder(141 source_container_client=variables.source_container_client,142 object_name=folder_name,143 blob_service_client=variables.blob_service_client,144 container_name=variables.container_name,145 target_container=variables.target_container,146 path=path,147 storage_tier=variables.storage_tier,148 category='folder',149 )150 blobs = variables.target_container_client.list_blobs()151 for blob in blobs:152 if blob.name == os.path.join(path, check_file):153 assert blob.blob_tier == variables.storage_tier154 original_blobs = variables.source_container_client.list_blobs()155 assert folder_name in [os.path.dirname(blob.name) for blob in original_blobs]156157158def test_copy_container(variables):159 path = 'nested_container'160 AzureContainerMove.move_container(161 source_container_client=variables.source_container_client,162 blob_service_client=variables.blob_service_client,163 container_name=variables.container_name,164 target_container=variables.target_container,165 path=path,166 storage_tier=variables.storage_tier,167 )168 blobs = variables.target_container_client.list_blobs()169 assert os.path.join(path, 'file_2.txt') in [blob.name for blob in blobs]170 original_blobs = variables.source_container_client.list_blobs()171 assert original_blobs172173174@patch('argparse.ArgumentParser.parse_args')175def test_copy_file_integration(mock_args, variables):176 file_name = 'file_1.txt'177 reset_path = 'file_integration'178 rename = 'file_1_copy.txt'179 mock_args.return_value = argparse.Namespace(180 account_name=variables.account_name,181 container_name=variables.container_name,182 target_container=variables.target_container,183 reset_path=reset_path,184 verbosity='info',185 file=file_name,186 storage_tier=variables.storage_tier,187 name=rename,188 copy=True,189 )190 arguments = cli()191 file_copy(arguments)192 blobs = variables.target_container_client.list_blobs()193 assert os.path.join(reset_path, rename) in [blob.name for blob in blobs]194195196@pytest.mark.parametrize('file_name,path,rename',197 [('file_1.txt', '', ''),198 ('nested_folder/folder_test_1.txt', 'nested_folder', 'folder_test_1.txt'),199 ('nested_folder/folder_test_1.txt', 'nested_folder', ''),200 ('file_1.txt', None, '')])201@patch('argparse.ArgumentParser.parse_args')202def test_copy_file_duplicate_integration(mock_args, variables, file_name, path, rename):203 with pytest.raises(SystemExit):204 mock_args.return_value = argparse.Namespace(205 account_name=variables.account_name,206 container_name=variables.container_name,207 target_container=variables.container_name,208 reset_path=path,209 verbosity='info',210 file=file_name,211 storage_tier=variables.storage_tier,212 name=rename,213 copy=True,214 )215 arguments = cli()216 file_copy(arguments)217218219@patch('argparse.ArgumentParser.parse_args')220def test_copy_file_integration_cool(mock_args, variables):221 file_name = 'nested_file_1.txt'222 reset_path = 'cool_file_integration'223 storage_tier = 'Cool'224 rename = 'nested_file_1_copy.txt'225 mock_args.return_value = argparse.Namespace(226 account_name=variables.account_name,227 container_name=variables.container_name,228 target_container=variables.target_container,229 reset_path=reset_path,230 verbosity='info',231 file=file_name,232 storage_tier=storage_tier,233 name=rename,234 copy=True,235 )236 arguments = cli()237 file_copy(arguments)238 blobs = variables.target_container_client.list_blobs()239 for blob in blobs:240 if blob.name == os.path.join(reset_path, rename):241 assert blob.blob_tier == storage_tier242243244@patch('argparse.ArgumentParser.parse_args')245def test_copy_folder_integration(mock_args, variables):246 folder_name = 'nested_folder_5'247 reset_path = 'folder_integration'248 mock_args.return_value = argparse.Namespace(249 account_name=variables.account_name,250 container_name=variables.container_name,251 target_container=variables.target_container,252 reset_path=reset_path,253 verbosity='info',254 folder=folder_name,255 storage_tier=variables.storage_tier,256 copy=True,257 )258 arguments = cli()259 folder_copy(arguments)260 blobs = variables.target_container_client.list_blobs()261 assert os.path.join(reset_path, 'nested_folder_test_1.txt') in [blob.name for blob in blobs]262 original_blobs = variables.source_container_client.list_blobs()263 assert folder_name in [os.path.dirname(blob.name) for blob in original_blobs]264265266@patch('argparse.ArgumentParser.parse_args')267def test_copy_container_integration(mock_args, variables):268 reset_path = 'container_integration'269 mock_args.return_value = argparse.Namespace(270 account_name=variables.account_name,271 container_name=variables.container_name,272 target_container=variables.target_container,273 reset_path=reset_path,274 verbosity='info',275 storage_tier=variables.storage_tier,276 copy=True,277 )278 arguments = cli()279 container_copy(arguments)280 blobs = variables.target_container_client.list_blobs()281 assert os.path.join(reset_path, 'double_nested_file_1.txt') in [blob.name for blob in blobs]282 original_blobs = variables.source_container_client.list_blobs() ...

Full Screen

Full Screen

test_azure_4_move.py

Source:test_azure_4_move.py Github

copy

Full Screen

1from azure_storage.methods import move_prep2from azure_storage.azure_move import \3 AzureContainerMove, \4 AzureMove, \5 cli, \6 container_move, \7 file_move, \8 folder_move9from unittest.mock import patch10import argparse11import pytest12import azure13import os141516@pytest.fixture(name='variables', scope='module')17def setup():18 class Variables:19 def __init__(self):20 self.account_name = 'carlingst01'21 self.container_name = '00000container'22 self.target_container = '000000container'23 self.storage_tier = 'Hot'2425 return Variables()262728def run_move_prep(variables):29 variables.container_name, variables.target_container, variables.blob_service_client, \30 variables.source_container_client, variables.target_container_client = move_prep(31 account_name=variables.account_name,32 container_name=variables.container_name,33 target_container=variables.target_container34 )353637def test_move_prep(variables):38 run_move_prep(variables=variables)39 assert type(variables.source_container_client) is azure.storage.blob._container_client.ContainerClient404142def test_move_prep_target_exists(variables):43 run_move_prep(variables=variables)44 assert type(variables.target_container_client) is azure.storage.blob._container_client.ContainerClient454647@pytest.mark.parametrize('file_name,path',48 [('file_1.txt', ''),49 ('file_1', ''),50 ('file_1.gz', ''),51 ('file_2.txt', 'nested'),52 ('nested_folder/folder_test_1.txt', ''),53 ('nested_folder/nested_folder_2/nested_folder_test_1.txt', 'ABC'),54 ('nested_folder/nested_folder_2/nested_folder_test_1.txt', 'ABC/123'),55 ('nested/file_2.txt', 'nested_folder_2')])56def test_move_file(variables, file_name, path):57 AzureMove.move_file(58 source_container_client=variables.source_container_client,59 object_name=file_name,60 blob_service_client=variables.blob_service_client,61 container_name=variables.container_name,62 target_container=variables.target_container,63 path=path,64 storage_tier=variables.storage_tier65 )66 blobs = variables.target_container_client.list_blobs()67 assert os.path.join(path, os.path.basename(file_name)) in [blob.name for blob in blobs]686970@pytest.mark.parametrize('file_name,path',71 [('file_7.txt', ''),72 ('nonexistent/file_2.txt', 'nested_2'),73 ('nested/file_3.txt', 'nested_folder_2')])74def test_move_file_invalid(variables, file_name, path):75 with pytest.raises(SystemExit):76 AzureMove.move_file(77 source_container_client=variables.source_container_client,78 object_name=file_name,79 blob_service_client=variables.blob_service_client,80 container_name=variables.container_name,81 target_container=variables.target_container,82 path=path,83 storage_tier=variables.storage_tier84 )858687@pytest.mark.parametrize('file_name,path',88 [('nested_file_1.txt', ''),89 ('nested_folder/nested_file_2.txt', 'nested')])90def test_move_file_cool(variables, file_name, path):91 storage_tier = 'Cool'92 AzureMove.move_file(93 source_container_client=variables.source_container_client,94 object_name=file_name,95 blob_service_client=variables.blob_service_client,96 container_name=variables.container_name,97 target_container=variables.target_container,98 path=path,99 storage_tier=storage_tier100 )101 blobs = variables.target_container_client.list_blobs()102 for blob in blobs:103 if blob.name == os.path.join(path, file_name):104 assert blob.blob_tier == storage_tier105106107@pytest.mark.parametrize('folder_name,path,check_file',108 [('single_nested', '', 'triple_nested_file.txt'),109 ('nested_folder/nested_folder_2', 'nested_folder_3', 'nested_folder_test_1.txt'),110 ('nested_folder/nested_folder_2', '', 'nested_folder_test_1.txt')])111def test_move_folder(variables, folder_name, path, check_file):112 AzureMove.move_folder(113 source_container_client=variables.source_container_client,114 object_name=folder_name,115 blob_service_client=variables.blob_service_client,116 container_name=variables.container_name,117 target_container=variables.target_container,118 path=path,119 storage_tier=variables.storage_tier,120 category='folder'121 )122 blobs = variables.target_container_client.list_blobs()123 assert os.path.join(path, os.path.basename(check_file)) in [blob.name for blob in blobs]124125126@pytest.mark.parametrize('folder_name,path,check_file',127 [('cool/nested_folder_2', '', 'nested_folder_test_1.txt'),128 ('cool_nested_folder_5', 'hot', 'nested_folder_test_1.txt')])129def test_move_folder_cool(variables, folder_name, path, check_file):130 AzureMove.move_folder(131 source_container_client=variables.source_container_client,132 object_name=folder_name,133 blob_service_client=variables.blob_service_client,134 container_name=variables.container_name,135 target_container=variables.target_container,136 path=path,137 storage_tier=variables.storage_tier,138 category='folder'139 )140 blobs = variables.target_container_client.list_blobs()141 for blob in blobs:142 if blob.name == os.path.join(path, check_file):143 assert blob.blob_tier == variables.storage_tier144145146@pytest.mark.parametrize('folder_name,path',147 [('nested_folder_6', ''),148 ('nested_folder_2/nested_folder_2', 'nested_folder'),149 ('nested_folder/nested_folder_3', '')])150def test_move_folder_invalid(variables, folder_name, path):151 with pytest.raises(SystemExit):152 AzureMove.move_folder(153 source_container_client=variables.source_container_client,154 object_name=folder_name,155 blob_service_client=variables.blob_service_client,156 container_name=variables.container_name,157 target_container=variables.target_container,158 path=path,159 storage_tier=variables.storage_tier,160 category='folder'161 )162163164def test_move_folder_invalid_category(variables):165 with pytest.raises(SystemExit):166 move_folder = AzureMove(167 object_name='cool/nested_folder_2',168 container_name=variables.container_name,169 account_name=variables.account_name,170 target_container=variables.target_container,171 path=None,172 storage_tier=variables.storage_tier,173 category='container'174 )175 move_folder.main()176177178def test_move_container(variables):179 path = 'nested_container'180 AzureContainerMove.move_container(181 source_container_client=variables.source_container_client,182 blob_service_client=variables.blob_service_client,183 container_name=variables.container_name,184 target_container=variables.target_container,185 path=path,186 storage_tier=variables.storage_tier187 )188 blobs = variables.target_container_client.list_blobs()189 assert os.path.join(path, 'file_2.txt') in [blob.name for blob in blobs]190191192@patch('argparse.ArgumentParser.parse_args')193def test_move_file_integration(mock_args, variables):194 file_name = 'file_1.txt'195 reset_path = 'file_integration'196 mock_args.return_value = argparse.Namespace(197 account_name=variables.account_name,198 container_name=variables.container_name,199 target_container=variables.target_container,200 reset_path=reset_path,201 verbosity='info',202 file=file_name,203 storage_tier=variables.storage_tier204 )205 arguments = cli()206 file_move(arguments)207 blobs = variables.target_container_client.list_blobs()208 assert os.path.join(reset_path, file_name) in [blob.name for blob in blobs]209210211@patch('argparse.ArgumentParser.parse_args')212def test_move_file_integration_cool(mock_args, variables):213 file_name = 'nested_file_1.txt'214 reset_path = 'cool_file_integration'215 storage_tier = 'Cool'216 mock_args.return_value = argparse.Namespace(217 account_name=variables.account_name,218 container_name=variables.container_name,219 target_container=variables.target_container,220 reset_path=reset_path,221 verbosity='info',222 file=file_name,223 storage_tier=storage_tier224 )225 arguments = cli()226 file_move(arguments)227 blobs = variables.target_container_client.list_blobs()228 for blob in blobs:229 if blob.name == os.path.join(reset_path, file_name):230 assert blob.blob_tier == storage_tier231232233@patch('argparse.ArgumentParser.parse_args')234def test_move_folder_integration(mock_args, variables):235 folder_name = 'nested_folder_5'236 reset_path = 'folder_integration'237 mock_args.return_value = argparse.Namespace(238 account_name=variables.account_name,239 container_name=variables.container_name,240 target_container=variables.target_container,241 reset_path=reset_path,242 verbosity='info',243 folder=folder_name,244 storage_tier=variables.storage_tier245 )246 arguments = cli()247 folder_move(arguments)248 blobs = variables.target_container_client.list_blobs()249 assert os.path.join(reset_path, 'nested_folder_test_1.txt') in [blob.name for blob in blobs]250251252@patch('argparse.ArgumentParser.parse_args')253def test_move_container_integration(mock_args, variables):254 reset_path = 'container_integration'255 mock_args.return_value = argparse.Namespace(256 account_name=variables.account_name,257 container_name=variables.container_name,258 target_container=variables.target_container,259 reset_path=reset_path,260 verbosity='info',261 storage_tier=variables.storage_tier)262 arguments = cli()263 container_move(arguments)264 blobs = variables.target_container_client.list_blobs() ...

Full Screen

Full Screen

paths.py

Source:paths.py Github

copy

Full Screen

...22 compat_ostype.append("Linux") # freebsd has the linux compatibility layer.23 if (ostype == "Darwin" and machtype == "arm64"):24 compat_machtype.append("x86_64") # macosx has rosetta2, allowing it to run x86_64 binaries.25 # reset the paths26 shell.reset_path("PATH")27 shell.reset_path("MANPATH")28 shell.reset_path("INFOPATH")29 shell.reset_path("LD_LIBRARY_PATH")30 shell.reset_path("PYTHONPATH")31 shell.reset_path("INCLUDE_PATH")32 shell.reset_path("LIB_PATH")33 prefixes = [{'path': os.path.join(home, "software"),34 'development_paths': True}]35 for mt in compat_machtype:36 for ost in compat_ostype:37 prefixes.append({'path': os.path.join(home, "software",38 "%s-%s" % (mt, ost)),39 'development_paths': True})40 prefixes.extend([41 {'path': os.path.join(os.sep, "usr", "local"), 'sbin_paths': True},42 {'path': os.path.join(os.sep, "opt", "local"), 'sbin_paths': True},43 {'path': os.path.join(os.sep, "usr"), 'sbin_paths': True},44 {'path': os.path.join(os.sep, "opt"), 'sbin_paths': True},45 {'path': os.path.join(os.sep), 'sbin_paths': True},46 {'path': os.path.join(os.sep, "usr", "X11R6"), 'sbin_paths': True},...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful