Skip to content

Commit d6786aa

Browse files
committed
Merge pull request #23 from switch-ch/master
add test_dirDelete test
2 parents c0d35a2 + b68bb7b commit d6786aa

2 files changed

Lines changed: 65 additions & 1 deletion

File tree

‎lib/test_dirDelete.py‎

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
from smashbox.utilities import *
2+
3+
__doc__ = """ This test creates a deeply nested directory structure and then removes it
4+
5+
"""
6+
7+
8+
import os.path
9+
10+
NESTING_LEVELS = config.get('dirDel_nestingLevels', 50)
11+
12+
nfiles = int(config.get('dirDel_nfiles', 100))
13+
14+
TEST_FILES = ['test%02d.dat'%i for i in range(nfiles)]
15+
16+
@add_worker
17+
def workerA(step):
18+
19+
#cleanup remote and local test environment - this should be run once by one worker only
20+
reset_owncloud_account()
21+
reset_rundir()
22+
23+
step(0,'create initial content and sync')
24+
25+
# this will be our syncdir (this is different for every worker)
26+
syncdir = make_workdir()
27+
28+
# create a folder and some files in it
29+
path = "0"
30+
for i in xrange(1, NESTING_LEVELS):
31+
path = path + "/" + str(i)
32+
d1 = mkdir(os.path.join(syncdir, path))
33+
34+
for f in TEST_FILES:
35+
fn = os.path.join(d1,f)
36+
createfile(fn,'0',count=1,bs=1000)
37+
38+
run_ocsync(syncdir)
39+
40+
step(2,'delete the folder and sync')
41+
42+
topLevelDir = path.split("/", 1)[0]
43+
d2 = os.path.join(syncdir, topLevelDir)
44+
45+
remove_tree(d2)
46+
47+
#createfile(os.path.join(syncdir,'touch'),'0',count=1,bs=1)
48+
49+
expect_webdav_exist(topLevelDir)
50+
run_ocsync(syncdir)
51+
52+
expect_does_not_exist(d2)
53+
expect_webdav_does_not_exist(topLevelDir)
54+

‎python/smashbox/utilities/__init__.py‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,16 @@ def run_ocsync(local_folder, remote_folder="", n=None, user_num=None):
279279
def webdav_propfind_ls(path):
280280
runcmd('curl -s -k %s -XPROPFIND %s | xmllint --format -'%(config.get('curl_opts',''),oc_webdav_url(remote_folder=path)))
281281

282+
def expect_webdav_does_not_exist(path):
283+
exitcode,stdout,stderr = runcmd('curl -s -k %s -XPROPFIND %s | xmllint --format - | grep NotFound | wc -l'%(config.get('curl_opts',''),oc_webdav_url(remote_folder=path)))
284+
exists = stdout.rstrip() == "1"
285+
error_check(exists, "Remote path does not %s exist but should" % path)
286+
287+
def expect_webdav_exist(path):
288+
exitcode,stdout,stderr = runcmd('curl -s -k %s -XPROPFIND %s | xmllint --format - | grep NotFound | wc -l'%(config.get('curl_opts',''),oc_webdav_url(remote_folder=path)))
289+
exists = stdout.rstrip() == "0"
290+
error_check(exists, "Remote path %s exists but should not" % path)
291+
282292
def webdav_delete(path):
283293
runcmd('curl -k %s -X DELETE %s '%(config.get('curl_opts',''),oc_webdav_url(remote_folder=path)))
284294

@@ -312,7 +322,7 @@ def runcmd(cmd,ignore_exitcode=False,echo=True,allow_stderr=True,shell=True,log_
312322
if not ignore_exitcode:
313323
raise subprocess.CalledProcessError(process.returncode,cmd)
314324

315-
return process.returncode
325+
return (process.returncode, stdout, stderr)
316326

317327

318328
def sleep(n):

0 commit comments

Comments
 (0)