From c6f1a16357b05d0dedf868ebfb4147d3bd2d85f0 Mon Sep 17 00:00:00 2001 From: swoichha Date: Fri, 1 Oct 2021 14:49:43 +0545 Subject: [PATCH] combine when steps into one --- test/gui/shared/steps/steps.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/test/gui/shared/steps/steps.py b/test/gui/shared/steps/steps.py index 1135abc058e..47eafa5702e 100644 --- a/test/gui/shared/steps/steps.py +++ b/test/gui/shared/steps/steps.py @@ -851,11 +851,12 @@ def step(context, errorMsg): test.compare(str(waitForObjectExists(newAccount.ERROR_LABEL).text), errorMsg) -@When('the user deletes the file "|any|"') -def step(context, fileName): - os.remove(context.userData['clientSyncPathUser1'] + fileName) - - -@When('the user deletes the folder "|any|"') -def step(context, folderName): - shutil.rmtree(context.userData['clientSyncPathUser1'] + folderName) +@When(r'the user deletes the (file|folder) "([^"]*)"', regexp=True) +def step(context, itemType, resource): + resourcePath = sanitizePath(context.userData['clientSyncPathUser1'] + resource) + if itemType == 'file': + os.remove(resourcePath) + elif itemType == 'folder': + shutil.rmtree(resourcePath) + else: + raise Exception("No such item type for resource")