Skip to content

Commit f183837

Browse files
committed
Merge pull request #130 from owncloud/full-subfolder-download
Add a test to download a full subfolder
2 parents c77aab7 + e1add89 commit f183837

File tree

1 file changed

+73
-1
lines changed

1 file changed

+73
-1
lines changed

lib/oc-tests/test_shareLink.py

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
{
3232
'test_downloader': 'full_folder'
3333
},
34+
{
35+
'test_downloader': 'full_subfolder'
36+
},
3437
{
3538
'test_downloader': 'selected_files'
3639
}
@@ -62,16 +65,23 @@ def sharer(step):
6265
step(3, 'Create initial test files and directories')
6366

6467
proc_name = reflection.getProcessName()
65-
dir_name = "%s/%s" % (proc_name, 'localShareDir')
68+
dir_name = os.path.join(proc_name, 'localShareDir')
6669
local_dir = make_workdir(dir_name)
70+
subdir_dir = make_workdir(os.path.join(dir_name, 'subdir'))
6771

6872
createfile(os.path.join(local_dir, 'TEST_FILE_LINK_SHARE1.txt'), '1', count=1000, bs=filesize_kb)
6973
createfile(os.path.join(local_dir, 'TEST_FILE_LINK_SHARE2.txt'), '2', count=1000, bs=filesize_kb)
7074
createfile(os.path.join(local_dir, 'TEST_FILE_LINK_SHARE3.txt'), '3', count=1000, bs=filesize_kb)
75+
createfile(os.path.join(subdir_dir, 'TEST_FILE_LINK_SHARE4.txt'), '4', count=1000, bs=filesize_kb)
76+
createfile(os.path.join(subdir_dir, 'TEST_FILE_LINK_SHARE5.txt'), '5', count=1000, bs=filesize_kb)
77+
createfile(os.path.join(subdir_dir, 'TEST_FILE_LINK_SHARE6.txt'), '6', count=1000, bs=filesize_kb)
7178
shared = reflection.getSharedObject()
7279
shared['MD5_TEST_FILE_LINK_SHARE1'] = md5sum(os.path.join(local_dir, 'TEST_FILE_LINK_SHARE1.txt'))
7380
shared['MD5_TEST_FILE_LINK_SHARE2'] = md5sum(os.path.join(local_dir, 'TEST_FILE_LINK_SHARE2.txt'))
7481
shared['MD5_TEST_FILE_LINK_SHARE3'] = md5sum(os.path.join(local_dir, 'TEST_FILE_LINK_SHARE3.txt'))
82+
shared['MD5_TEST_FILE_LINK_SHARE4'] = md5sum(os.path.join(subdir_dir, 'TEST_FILE_LINK_SHARE4.txt'))
83+
shared['MD5_TEST_FILE_LINK_SHARE5'] = md5sum(os.path.join(subdir_dir, 'TEST_FILE_LINK_SHARE5.txt'))
84+
shared['MD5_TEST_FILE_LINK_SHARE6'] = md5sum(os.path.join(subdir_dir, 'TEST_FILE_LINK_SHARE6.txt'))
7585

7686
list_files(d)
7787
run_ocsync(d, user_num=1)
@@ -175,6 +185,10 @@ def public_downloader_full_folder(step):
175185
expect_exists(os.path.join(unzip_target, 'localShareDir', 'TEST_FILE_LINK_SHARE1.txt'))
176186
expect_exists(os.path.join(unzip_target, 'localShareDir', 'TEST_FILE_LINK_SHARE2.txt'))
177187
expect_exists(os.path.join(unzip_target, 'localShareDir', 'TEST_FILE_LINK_SHARE3.txt'))
188+
expect_exists(os.path.join(unzip_target, 'localShareDir', 'subdir'))
189+
expect_exists(os.path.join(unzip_target, 'localShareDir', 'subdir', 'TEST_FILE_LINK_SHARE4.txt'))
190+
expect_exists(os.path.join(unzip_target, 'localShareDir', 'subdir', 'TEST_FILE_LINK_SHARE5.txt'))
191+
expect_exists(os.path.join(unzip_target, 'localShareDir', 'subdir', 'TEST_FILE_LINK_SHARE6.txt'))
178192

179193
expect_not_modified(
180194
os.path.join(unzip_target, 'localShareDir', 'TEST_FILE_LINK_SHARE1.txt'),
@@ -188,6 +202,62 @@ def public_downloader_full_folder(step):
188202
os.path.join(unzip_target, 'localShareDir', 'TEST_FILE_LINK_SHARE3.txt'),
189203
shared['MD5_TEST_FILE_LINK_SHARE3']
190204
)
205+
expect_not_modified(
206+
os.path.join(unzip_target, 'localShareDir', 'subdir', 'TEST_FILE_LINK_SHARE4.txt'),
207+
shared['MD5_TEST_FILE_LINK_SHARE4']
208+
)
209+
expect_not_modified(
210+
os.path.join(unzip_target, 'localShareDir', 'subdir', 'TEST_FILE_LINK_SHARE5.txt'),
211+
shared['MD5_TEST_FILE_LINK_SHARE5']
212+
)
213+
expect_not_modified(
214+
os.path.join(unzip_target, 'localShareDir', 'subdir', 'TEST_FILE_LINK_SHARE6.txt'),
215+
shared['MD5_TEST_FILE_LINK_SHARE6']
216+
)
217+
218+
219+
def public_downloader_full_subfolder(step):
220+
221+
step(2, 'Create workdir')
222+
d = make_workdir()
223+
224+
step(5, 'Downloads and validate')
225+
226+
shared = reflection.getSharedObject()
227+
url = oc_webdav_url(
228+
remote_folder=os.path.join(
229+
'index.php',
230+
's',
231+
shared['SHARE_LINK_TOKEN_TEST_DIR'],
232+
'download?path=%2F&files=subdir'
233+
),
234+
webdav_endpoint=config.oc_root
235+
)
236+
237+
download_target = os.path.join(d, '%s%s' % (shared['SHARE_LINK_TOKEN_TEST_DIR'], '.zip'))
238+
unzip_target = os.path.join(d, 'unzip')
239+
runcmd('curl -v -k %s -o \'%s\' \'%s\'' % (config.get('curl_opts', ''), download_target, url))
240+
runcmd('unzip -d %s %s' % (unzip_target, download_target))
241+
242+
list_files(d, recursive=True)
243+
244+
expect_exists(os.path.join(unzip_target, 'subdir'))
245+
expect_exists(os.path.join(unzip_target, 'subdir', 'TEST_FILE_LINK_SHARE4.txt'))
246+
expect_exists(os.path.join(unzip_target, 'subdir', 'TEST_FILE_LINK_SHARE5.txt'))
247+
expect_exists(os.path.join(unzip_target, 'subdir', 'TEST_FILE_LINK_SHARE6.txt'))
248+
249+
expect_not_modified(
250+
os.path.join(unzip_target, 'subdir', 'TEST_FILE_LINK_SHARE4.txt'),
251+
shared['MD5_TEST_FILE_LINK_SHARE4']
252+
)
253+
expect_not_modified(
254+
os.path.join(unzip_target, 'subdir', 'TEST_FILE_LINK_SHARE5.txt'),
255+
shared['MD5_TEST_FILE_LINK_SHARE5']
256+
)
257+
expect_not_modified(
258+
os.path.join(unzip_target, 'subdir', 'TEST_FILE_LINK_SHARE6.txt'),
259+
shared['MD5_TEST_FILE_LINK_SHARE6']
260+
)
191261

192262

193263
def public_downloader_selected_files(step):
@@ -237,5 +307,7 @@ def public_downloader_selected_files(step):
237307
add_worker(public_downloader_selected_single_files, name=test_downloader)
238308
elif test_downloader == 'full_folder':
239309
add_worker(public_downloader_full_folder, name=test_downloader)
310+
elif test_downloader == 'full_subfolder':
311+
add_worker(public_downloader_full_subfolder, name=test_downloader)
240312
elif test_downloader == 'selected_files':
241313
add_worker(public_downloader_selected_files, name=test_downloader)

0 commit comments

Comments
 (0)