Skip to content

Commit 25ed6aa

Browse files
committed
add step to copy-paste virtual file in same location
1 parent d9ef302 commit 25ed6aa

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

test/gui/shared/steps/file_context.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,14 @@ def extractZip(zip_file_path, destination_dir):
9696
zipFile.extractall(destination_dir)
9797

9898

99+
def addCopySuffix(resource_path, resource_type):
100+
if resource_type == "file":
101+
source_dir = resource_path.rsplit('.', 1)
102+
return source_dir[0] + " - Copy." + source_dir[-1]
103+
else:
104+
return resource_path + " - Copy"
105+
106+
99107
@When(
100108
'user "|any|" creates a file "|any|" with the following content inside the sync folder'
101109
)
@@ -123,12 +131,14 @@ def step(context, username, filename, filesize):
123131

124132
@When(r'the user copies the (file|folder) "([^"]*)" to "([^"]*)"', regexp=True)
125133
def step(context, resource_type, source_dir, destination_dir):
126-
source_dir = getResourcePath(source_dir)
127-
destination_dir = getResourcePath(destination_dir)
134+
source_dir_path = getResourcePath(source_dir)
135+
destination_dir_path = getResourcePath(destination_dir)
136+
if source_dir_path == destination_dir_path or destination_dir == '/':
137+
destination_dir_path = addCopySuffix(source_dir_path, resource_type)
128138
if resource_type == 'folder':
129-
return shutil.copytree(source_dir, destination_dir)
139+
return shutil.copytree(source_dir_path, destination_dir_path)
130140
else:
131-
return shutil.copy2(source_dir, destination_dir)
141+
return shutil.copy2(source_dir_path, destination_dir_path)
132142

133143

134144
@When(r'the user renames a (?:file|folder) "([^"]*)" to "([^"]*)"', regexp=True)

test/gui/tst_vfs/test.feature

+7
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,26 @@ Feature: Enable/disable virtual file support
3838
Given user "Alice" has been created on the server with default attributes and without skeleton files
3939
And user "Alice" has uploaded file with content "sample file" to "sampleFile.txt" in the server
4040
And user "Alice" has uploaded file with content "lorem file" to "lorem.txt" in the server
41+
And user "Alice" has uploaded file with content "test file" to "testFile.txt" in the server
4142
And user "Alice" has created folder "Folder" in the server
4243
And user "Alice" has set up a client with default settings
4344
Then the placeholder of file "lorem.txt" should exist on the file system
4445
And the placeholder of file "sampleFile.txt" should exist on the file system
46+
And the placeholder of file "testFile.txt" should exist on the file system
4547
When user "Alice" copies file "sampleFile.txt" to temp folder
4648
And the user copies the file "lorem.txt" to "Folder"
49+
And the user copies the file "testFile.txt" to "testFile.txt"
4750
And the user waits for file "Folder/lorem.txt" to be synced
4851
Then the file "sampleFile.txt" should be downloaded
4952
And the file "Folder/lorem.txt" should be downloaded
5053
And the file "lorem.txt" should be downloaded
54+
And the file "testFile.txt" should be downloaded
55+
And the file "testFile - Copy.txt" should be downloaded
5156
And as "Alice" file "Folder/lorem.txt" should exist in the server
5257
And as "Alice" file "lorem.txt" should exist in the server
5358
And as "Alice" file "sampleFile.txt" should exist in the server
59+
And as "Alice" file "testFile.txt" should exist in the server
60+
And as "Alice" file "testFile - Copy.txt" should exist in the server
5461

5562

5663
Scenario: Move virtual file

0 commit comments

Comments
 (0)