@@ -96,6 +96,11 @@ def extractZip(zip_file_path, destination_dir):
96
96
zipFile .extractall (destination_dir )
97
97
98
98
99
+ def addCopySuffix (file_path ):
100
+ source_dir = file_path .rsplit ('.' , 1 )
101
+ return source_dir [0 ] + " - Copy." + source_dir [- 1 ]
102
+
103
+
99
104
@When (
100
105
'user "|any|" creates a file "|any|" with the following content inside the sync folder'
101
106
)
@@ -123,12 +128,16 @@ def step(context, username, filename, filesize):
123
128
124
129
@When (r'the user copies the (file|folder) "([^"]*)" to "([^"]*)"' , regexp = True )
125
130
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 )
128
133
if resource_type == 'folder' :
129
- return shutil .copytree (source_dir , destination_dir )
134
+ return shutil .copytree (source_dir_path , destination_dir_path )
130
135
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 )
132
141
133
142
134
143
@When (r'the user renames a (?:file|folder) "([^"]*)" to "([^"]*)"' , regexp = True )
0 commit comments