44from os .path import exists , join
55import os
66import tarfile
7+ import shutil
78
89from .test_utils import CliShedTestCase
910
@@ -47,6 +48,16 @@ def test_cannont_recreate(self):
4748 self ._check_exit_code (create_command )
4849 self ._check_exit_code (create_command , exit_code = 1 )
4950
51+ def test_upload_recusrive (self ):
52+ with self ._isolate_repo ("multi_repos_nested" ) as f :
53+ upload_command = [
54+ "shed_upload" , "-r" , "--force_repository_creation"
55+ ]
56+ upload_command .extend (self ._shed_args ())
57+ self ._check_exit_code (upload_command )
58+ self ._verify_upload (f , ["cat1.xml" , "macros.xml" ], ["cat1" ])
59+ self ._verify_upload (f , ["cat2.xml" , "macros.xml" ], ["cat2" ])
60+
5061 def test_upload_filters_invalid_suite (self ):
5162 with self ._isolate_repo ("suite_1" ) as f :
5263 # No .shed.yml, make sure to test it can infer type
@@ -85,11 +96,16 @@ def test_upload_not_filters_unrestricted(self):
8596 assert exists (join (target , "README.rst" ))
8697
8798 def _verify_single_uploaded (self , f ):
88- target = self ._download_repo (f )
89- assert exists (join (target , "cat.xml" ))
99+ self ._verify_upload (f , ["cat.xml" ])
100+
101+ def _verify_upload (self , f , download_files = [], download_args = []):
102+ target = self ._download_repo (f , download_args )
103+ for download_file in download_files :
104+ assert exists (join (target , download_file ))
90105
91- def _download_repo (self , f ):
106+ def _download_repo (self , f , download_args = [] ):
92107 download_command = ["shed_download" ]
108+ download_command .extend (download_args )
93109 download_command .extend (self ._shed_args (read_only = True ))
94110 self ._check_exit_code (download_command )
95111 download = join (f , "shed_download.tar.gz" )
@@ -98,6 +114,8 @@ def _download_repo(self, f):
98114
99115 def _untar (self , f , path ):
100116 target = join (f , "download" )
117+ if exists (target ):
118+ shutil .rmtree (target )
101119 os .makedirs (target )
102120 tar = tarfile .open (path , "r:gz" )
103121 tar .extractall (path = target )
0 commit comments