4 new revisions:

Revision: 39a7b321d8e8
Branch:   default
Author:   Mikko Korpela <mikko.korp...@gmail.com>
Date:     Mon Dec  2 12:12:35 2013 UTC
Log: OperatingSystem.Copy File: Add tests for directory as destination (Fai...
http://code.google.com/p/robotframework/source/detail?r=39a7b321d8e8

Revision: 8d07471f2f39
Branch:   default
Author:   Mikko Korpela <mikko.korp...@gmail.com>
Date:     Mon Dec  2 13:25:11 2013 UTC
Log:      OperatingSystem: Fix destination is directory
http://code.google.com/p/robotframework/source/detail?r=8d07471f2f39

Revision: c43a7d29f034
Branch:   default
Author:   Mikko Korpela <mikko.korp...@gmail.com>
Date:     Mon Dec  2 13:27:48 2013 UTC
Log:      OperatingSystem: refactoring
http://code.google.com/p/robotframework/source/detail?r=c43a7d29f034

Revision: a30240dd1d9e
Branch:   default
Author:   Mikko Korpela <mikko.korp...@gmail.com>
Date:     Mon Dec  2 15:31:05 2013 UTC
Log:      merge
http://code.google.com/p/robotframework/source/detail?r=a30240dd1d9e

==============================================================================
Revision: 39a7b321d8e8
Branch:   default
Author:   Mikko Korpela <mikko.korp...@gmail.com>
Date:     Mon Dec  2 12:12:35 2013 UTC
Log: OperatingSystem.Copy File: Add tests for directory as destination (Failing currently)
http://code.google.com/p/robotframework/source/detail?r=39a7b321d8e8

Modified:
/atest/robot/standard_libraries/operating_system/file_and_dir_moving_and_copying.txt /atest/testdata/standard_libraries/operating_system/file_and_dir_moving_and_copying.txt

=======================================
--- /atest/robot/standard_libraries/operating_system/file_and_dir_moving_and_copying.txt Tue Nov 5 08:46:37 2013 UTC +++ /atest/robot/standard_libraries/operating_system/file_and_dir_moving_and_copying.txt Mon Dec 2 12:12:35 2013 UTC
@@ -10,6 +10,15 @@

 Copy File
     Check testcase  ${TESTNAME}
+
+Copy File when destination exists should be ok
+    Check testcase  ${TESTNAME}
+
+Copy File when destination is a directory
+    Check testcase  ${TESTNAME}
+
+Copy File when destination is a directory and file with same name exists
+    Check testcase  ${TESTNAME}

 Move File To Existing Dir
     Check testcase  ${TESTNAME}
=======================================
--- /atest/testdata/standard_libraries/operating_system/file_and_dir_moving_and_copying.txt Tue Nov 5 08:46:37 2013 UTC +++ /atest/testdata/standard_libraries/operating_system/file_and_dir_moving_and_copying.txt Mon Dec 2 12:12:35 2013 UTC
@@ -15,6 +15,28 @@
     Copy File  ${TESTFILE}  ${TESTFILE2}
     Verify File  ${TESTFILE2}  contents
Directory Should Have Items ${BASE} ${TESTFILE SHORT NAME} ${TESTFILE 2 SHORT NAME}
+
+Copy File when destination exists should be ok
+    Create File  ${TESTFILE}  contents
+    Copy File  ${TESTFILE}  ${TESTFILE2}
+    Create File  ${TESTFILE}  contents2
+    Copy File  ${TESTFILE}  ${TESTFILE2}
+    Verify File  ${TESTFILE2}  contents2
+
+Copy File when destination is a directory
+    ${destination}=    Set Variable    ${BASE}/foo
+    Create Directory   ${destination}
+    Create File  ${TESTFILE}  contents
+    Copy File    ${TESTFILE}  ${destination}
+    Verify File  ${destination}${/}${TESTFILE SHORT NAME}   contents
+
+Copy File when destination is a directory and file with same name exists
+    ${destination}=    Set Variable    ${BASE}/foo
+    Create Directory   ${destination}
+    Create File  ${TESTFILE}  contents
+    Create File  ${destination}${/}${TESTFILE SHORT NAME}   original
+    Copy File    ${TESTFILE}  ${destination}
+    Verify File  ${destination}${/}${TESTFILE SHORT NAME}   contents

 Move File To Existing Dir
     Create Directory  ${BASE}/foo

==============================================================================
Revision: 8d07471f2f39
Branch:   default
Author:   Mikko Korpela <mikko.korp...@gmail.com>
Date:     Mon Dec  2 13:25:11 2013 UTC
Log:      OperatingSystem: Fix destination is directory
http://code.google.com/p/robotframework/source/detail?r=8d07471f2f39

Modified:
 /src/robot/libraries/OperatingSystem.py

=======================================
--- /src/robot/libraries/OperatingSystem.py     Wed Nov 13 07:47:59 2013 UTC
+++ /src/robot/libraries/OperatingSystem.py     Mon Dec  2 13:25:11 2013 UTC
@@ -752,6 +752,9 @@
source, destination, dest_is_dir = self._normalize_dest_and_source(destination, source)
         self._verify_that_source_is_a_file(source)
         parent = self._ensure_directory_exists(destination, dest_is_dir)
+ dest = os.path.join(destination, os.path.basename(source)) if dest_is_dir else destination
+        if os.path.isfile(dest):
+            os.remove(dest)
         return source, destination, parent

     def _copy_file(self, source, destination):
@@ -761,7 +764,7 @@
     def _normalize_dest_and_source(self, dest, source):
         source = self._absnorm(source)
         dest = dest.replace('/', os.sep)
-        dest_is_dir = dest.endswith(os.sep)
+        dest_is_dir = dest.endswith(os.sep) or os.path.isdir(dest)
         dest = self._absnorm(dest)
         return source, dest, dest_is_dir


==============================================================================
Revision: c43a7d29f034
Branch:   default
Author:   Mikko Korpela <mikko.korp...@gmail.com>
Date:     Mon Dec  2 13:27:48 2013 UTC
Log:      OperatingSystem: refactoring
http://code.google.com/p/robotframework/source/detail?r=c43a7d29f034

Modified:
 /src/robot/libraries/OperatingSystem.py

=======================================
--- /src/robot/libraries/OperatingSystem.py     Mon Dec  2 13:25:11 2013 UTC
+++ /src/robot/libraries/OperatingSystem.py     Mon Dec  2 13:27:48 2013 UTC
@@ -752,10 +752,13 @@
source, destination, dest_is_dir = self._normalize_dest_and_source(destination, source)
         self._verify_that_source_is_a_file(source)
         parent = self._ensure_directory_exists(destination, dest_is_dir)
+ self._ensure_destination_file_does_not_exist(destination, dest_is_dir, source)
+        return source, destination, parent
+
+ def _ensure_destination_file_does_not_exist(self, destination, dest_is_dir, source): dest = os.path.join(destination, os.path.basename(source)) if dest_is_dir else destination
         if os.path.isfile(dest):
             os.remove(dest)
-        return source, destination, parent

     def _copy_file(self, source, destination):
source, destination, parent = self._prepare_for_move_or_copy(destination, source)

==============================================================================
Revision: a30240dd1d9e
Branch:   default
Author:   Mikko Korpela <mikko.korp...@gmail.com>
Date:     Mon Dec  2 15:31:05 2013 UTC
Log:      merge
http://code.google.com/p/robotframework/source/detail?r=a30240dd1d9e


--

--- You received this message because you are subscribed to the Google Groups "robotframework-commit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to robotframework-commit+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to