Skip to content

Commit

Permalink
added feature for moving file and folder (#10392)
Browse files Browse the repository at this point in the history
added step implementation for moving file and folder

addded tag for the feature

made similar step definition of moving files and folders into single step definition

renamed test folder

refined the sequence of steps

optimized steps

fixed indentation

changed function name
  • Loading branch information
Salipa-Gurung authored and individual-it committed Jan 24, 2023
1 parent 1bcf86f commit b0fd601
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/gui/shared/steps/file_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,15 @@ def step(context, username, foldername):
source_dir = join(context.userData['tempFolderPath'], foldername)
destination_dir = getResourcePath(context, '/', username)
shutil.move(source_dir, destination_dir)


@When(
r'user "([^"]*)" moves (file|folder) "([^"]*)" to "([^"]*)" in the sync folder',
regexp=True,
)
def step(context, username, resourceType, source, destination):
source_dir = getResourcePath(context, source, username)
if destination == None or destination == "/":
destination = ""
destination_dir = getResourcePath(context, destination, username)
shutil.move(source_dir, destination_dir)
44 changes: 44 additions & 0 deletions test/gui/tst_moveFilesFolders/test.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Feature: move file and folder

As a user
I want to be able to move a folder and a file
So that I can organize my files and folders


Background:
Given user "Alice" has been created on the server with default attributes and without skeleton files
And user "Alice" has created folder "folder1" on the server
And user "Alice" has created folder "folder1/folder2" on the server
And user "Alice" has created folder "folder1/folder2/folder3" on the server
And user "Alice" has created folder "folder1/folder2/folder3/folder4" on the server
And user "Alice" has created folder "folder1/folder2/folder3/folder4/folder5" on the server


Scenario: Move folder and file from level 5 sub-folder to sync root
Given user "Alice" has created folder "folder1/folder2/folder3/folder4/folder5/test-folder" on the server
And user "Alice" has uploaded file with content "ownCloud" to "folder1/folder2/folder3/folder4/folder5/lorem.txt" on the server
And user "Alice" has set up a client with default settings
When user "Alice" moves file "folder1/folder2/folder3/folder4/folder5/lorem.txt" to "/" in the sync folder
And user "Alice" moves folder "folder1/folder2/folder3/folder4/folder5/test-folder" to "/" in the sync folder
And the user waits for the files to sync
Then as "Alice" the file "lorem.txt" on the server should have the content "ownCloud"
And as "Alice" folder "test-folder" should exist on the server
And as "Alice" file "folder1/folder2/folder3/folder4/folder5/lorem.txt" should not exist on the server
And as "Alice" folder "folder1/folder2/folder3/folder4/folder5/test-folder" should not exist on the server


Scenario: Move two folders and a file down to the level 5 sub-folder
And user "Alice" has created folder "test-folder1" on the server
And user "Alice" has created folder "test-folder2" on the server
And user "Alice" has uploaded file with content "ownCloud test" to "testFile.txt" on the server
And user "Alice" has set up a client with default settings
When user "Alice" moves folder "test-folder1" to "folder1/folder2/folder3/folder4/folder5" in the sync folder
And user "Alice" moves folder "test-folder2" to "folder1/folder2/folder3/folder4/folder5" in the sync folder
And user "Alice" moves file "testFile.txt" to "folder1/folder2/folder3/folder4/folder5" in the sync folder
And the user waits for the files to sync
Then as "Alice" file "folder1/folder2/folder3/folder4/folder5/testFile.txt" should exist on the server
And as "Alice" folder "folder1/folder2/folder3/folder4/folder5/test-folder1" should exist on the server
And as "Alice" folder "folder1/folder2/folder3/folder4/folder5/test-folder2" should exist on the server
And as "Alice" file "testFile.txt" should not exist on the server
And as "Alice" folder "test-folder1" should not exist on the server
And as "Alice" folder "test-folder2" should not exist on the server
9 changes: 9 additions & 0 deletions test/gui/tst_moveFilesFolders/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
source(findFile('scripts', 'python/bdd.py'))

setupHooks('../shared/scripts/bdd_hooks.py')
collectStepDefinitions('./steps', '../shared/steps')


def main():
testSettings.throwOnFailure = True
runFeatureFile('test.feature')

0 comments on commit b0fd601

Please sign in to comment.