@@ -96,6 +96,14 @@ def extractZip(zip_file_path, destination_dir):
96
96
zipFile .extractall (destination_dir )
97
97
98
98
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
+
99
107
@When (
100
108
'user "|any|" creates a file "|any|" with the following content inside the sync folder'
101
109
)
@@ -123,12 +131,14 @@ def step(context, username, filename, filesize):
123
131
124
132
@When (r'the user copies the (file|folder) "([^"]*)" to "([^"]*)"' , regexp = True )
125
133
def step (context , resource_type , source_dir , destination_dir ):
126
- source_dir = getResourcePath (source_dir )
127
- destination_dir = getResourcePath (destination_dir )
134
+ source = getResourcePath (source_dir )
135
+ destination = getResourcePath (destination_dir )
136
+ if source == destination and destination_dir != '/' :
137
+ destination = addCopySuffix (source , resource_type )
128
138
if resource_type == 'folder' :
129
- return shutil .copytree (source_dir , destination_dir )
139
+ return shutil .copytree (source , destination )
130
140
else :
131
- return shutil .copy2 (source_dir , destination_dir )
141
+ return shutil .copy2 (source , destination )
132
142
133
143
134
144
@When (r'the user renames a (?:file|folder) "([^"]*)" to "([^"]*)"' , regexp = True )
0 commit comments