Skip to content

Commit 0a0038a

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

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

test/gui/shared/steps/file_context.py

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

9898

99+
def addCopySuffix(file_path):
100+
source_dir = file_path.rsplit('.', 1)
101+
return source_dir[0] + " - Copy." + source_dir[-1]
102+
103+
99104
@When(
100105
'user "|any|" creates a file "|any|" with the following content inside the sync folder'
101106
)
@@ -123,12 +128,16 @@ def step(context, username, filename, filesize):
123128

124129
@When(r'the user copies the (file|folder) "([^"]*)" to "([^"]*)"', regexp=True)
125130
def step(context, resource_type, source_dir, destination_dir):
126-
source_dir = getResourcePath(source_dir)
127-
destination_dir = getResourcePath(destination_dir)
131+
source_dir_path = getResourcePath(source_dir)
132+
destination_dir_path = getResourcePath(destination_dir)
128133
if resource_type == 'folder':
129-
return shutil.copytree(source_dir, destination_dir)
134+
return shutil.copytree(source_dir_path, destination_dir_path)
130135
else:
131-
return shutil.copy2(source_dir, destination_dir)
136+
try:
137+
return shutil.copy2(source_dir_path, destination_dir_path)
138+
except shutil.SameFileError:
139+
copy_of_source_dir = addCopySuffix(source_dir_path)
140+
return shutil.copy2(source_dir_path, copy_of_source_dir)
132141

133142

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

test/gui/tst_vfs/test.feature

+6
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,25 @@ 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
4546
When user "Alice" copies file "sampleFile.txt" to temp folder
4647
And the user copies the file "lorem.txt" to "Folder"
48+
And the user copies the file "testFile.txt" to "testFile.txt"
4749
And the user waits for file "Folder/lorem.txt" to be synced
4850
Then the file "sampleFile.txt" should be downloaded
4951
And the file "Folder/lorem.txt" should be downloaded
5052
And the file "lorem.txt" should be downloaded
53+
And the file "testFile.txt" should be downloaded
54+
And the file "testFile - Copy.txt" should be downloaded
5155
And as "Alice" file "Folder/lorem.txt" should exist in the server
5256
And as "Alice" file "lorem.txt" should exist in the server
5357
And as "Alice" file "sampleFile.txt" should exist in the server
58+
And as "Alice" file "testFile.txt" should exist in the server
59+
And as "Alice" file "testFile - Copy.txt" should exist in the server
5460

5561

5662
Scenario: Move virtual file

0 commit comments

Comments
 (0)