Revision: 4013d2e4c406
Author:   Anssi Syrjäsalo <anssi.syrjas...@eficode.com>
Date:     Tue Jul 30 08:47:58 2013
Log:      Handling slashes corrently in source paths

http://code.google.com/p/robotframework-sshlibrary/source/detail?r=4013d2e4c406

Modified:
 /atest/get_dir.txt
 /atest/put_dir.txt
 /atest/put_file.txt
 /src/SSHLibrary/abstractclient.py

=======================================
--- /atest/get_dir.txt  Tue Jul 30 03:56:32 2013
+++ /atest/get_dir.txt  Tue Jul 30 08:47:58 2013
@@ -2,10 +2,9 @@
 Force Tags      pybot   jybot
 Suite Setup     Login and Move Test Files
 Suite Teardown  Remove Test Files and Close Connections
-Test Teardown   Remove Directory  ${LOCAL TMPDIR}  True
+Test Teardown   Remove Directory  ${target}  True
 Resource        resources/ssh_library_resources.txt
 Library         OperatingSystem
-Library         Collections

 *** Test Cases ***
 Get Dir Using Absolute Source
@@ -20,39 +19,61 @@
     SSHLibrary.Get Dir  test_root  ${target}
     Directory Should Exist With Content  ${target}

-Get Dir Using Different Name
+Get Dir To Relative Destination
+    ${target} =  Set Variable  tmpdir
+    Directory Should Not Exist  ${target}
+    SSHLibrary.Get Dir  ${USER HOME}/test_root  ${target}
+    Directory Should Exist With Content  ${target}
+
+Get Dir To Current Destination
+    ${target} =  Set Variable  .${/}test_root
+    Directory Should Not Exist  ${target}
+    SSHLibrary.Get Dir  ${USER HOME}${/}test_root  .
+    Directory Should Exist With Content  .
+
+Get Dir To Different Name
     ${target} =  Set Variable  ${LOCAL TMPDIR}${/}foo
     Directory Should Not Exist  ${target}
-    SSHLibrary.Get Dir  ${USER HOME}/test_root   ${target}
+    SSHLibrary.Get Dir  ${USER HOME}${/}test_root   ${target}
     Directory Should Exist With Content  ${target}

-Get Dir With Subdirectories
+Get Dir Including Subdirectories
     ${target} =  Set Variable  ${LOCAL TMPDIR}
-    Directory Should Not Exist  ${target}
+    Directory Should Not Exist  ${target}/test_root
     SSHLibrary.Get Dir  ${USER HOME}/test_root  ${target}  recursive=True
     Directory Should Exist Including Subdirectories  ${target}
+
+Get Dir Content To Absolute Destination
+    ${target} =  Set Variable  ${LOCAL TMPDIR}
+    Directory Should Not Exist  ${target}
+    SSHLibrary.Get Dir  ${USER HOME}/test_root/  ${target}
+    File Should Exist  ${target}/${TEST SCRIPT NAME}
+    File Should Exist  ${target}/${REPEAT TEST SCRIPT NAME}
+
+Get Dir Content Including Subdirectories To Relative Destination
+    ${target} =  Set Variable  tmpdir
+    Directory Should Not Exist  ${target}
+    SSHLibrary.Get Dir  ${USER HOME}/test_root/  ${target}  recursive=True
+    File Should Exist  ${target}/${TEST SCRIPT NAME}
+    File Should Exist  ${target}/${REPEAT TEST SCRIPT NAME}
+    Directory Should Exist  ${target}/subdir
+    File Should Exist  ${target}/subdir/${INTERACTIVE TEST SCRIPT NAME}

 *** Keywords ***
 Directory Should Exist With Content
     [Arguments]  ${destination}
-    ${target_path} =  List Directory  ${destination}
-    ${expected} =  Create List  test_root
-    Lists Should Be Equal  ${target_path}  ${expected}
-    ${test_root} =  List Directory  ${destination}/test_root
- ${expected} = Create List ${TEST SCRIPT NAME} ${REPEAT TEST SCRIPT NAME}
-    Lists Should Be Equal  ${test_root}  ${expected}
+    Directory Should Exist  ${destination}/test_root
+    File Should Exist  ${destination}/test_root/${TEST SCRIPT NAME}
+    File Should Exist  ${destination}/test_root/${REPEAT TEST SCRIPT NAME}
+    Directory Should Not Exist  ${destination}/test_root/subdir

 Directory Should Exist Including Subdirectories
     [Arguments]  ${destination}
-    ${target_path} =  List Directory  ${destination}
-    ${expected} =  Create List  test_root
-    Lists Should Be Equal  ${target_path}  ${expected}
-    ${test_root} =  List Directory  ${destination}/test_root
- ${expected} = Create List subdir ${TEST SCRIPT NAME} ${REPEAT TEST SCRIPT NAME}
-    Lists Should Be Equal  ${test_root}  ${expected}
-    ${sub_dir} =  List Directory  ${destination}/test_root/subdir
-    ${expected} =  Create List  ${INTERACTIVE TEST SCRIPT NAME}
-    Lists Should Be Equal  ${sub_dir}  ${expected}
+    Directory Should Exist  ${destination}/test_root
+    File Should Exist  ${destination}/test_root/${TEST SCRIPT NAME}
+    File Should Exist  ${destination}/test_root/${REPEAT TEST SCRIPT NAME}
+    Directory Should Exist  ${destination}/test_root/subdir
+ File Should Exist ${destination}/test_root/subdir/${INTERACTIVE TEST SCRIPT NAME}

 Login And Move Test Files
     Login As Valid User
@@ -61,5 +82,5 @@
     Put File  ${REPEAT TEST SCRIPT}  ${USER HOME}/test_root/

 Remove Test Files and Close Connections
-    Execute Command  rm -rf ${USER HOME}/test_root
+    #Execute Command  rm -rf ${USER HOME}/test_root
     Close All Connections
=======================================
--- /atest/put_dir.txt  Tue Jul 30 03:56:32 2013
+++ /atest/put_dir.txt  Tue Jul 30 08:47:58 2013
@@ -6,13 +6,13 @@
 Resource        resources/ssh_library_resources.txt

 *** Test Cases ***
-Put Dir With Absolute Destination
+Put Dir To Absolute Destination
     ${target} =  Set Variable  ${USER HOME}/new_dir/
     Remote Directory Should Not Exist  ${target}
     Put Dir  ${TEXTFILES}  ${target}
     Remote Directory Should Exist With Content  ${target}/textfiles

-Put Dir With Relative Destination
+Put Dir To Relative Destination
     ${target} =  Set Variable  new_dir/
     Remote Directory Should Not Exist  ${target}
     Put Dir  ${TEXTFILES}   ${target}
@@ -24,13 +24,13 @@
     Put Dir  ${TEXTFILES}  ./
     Remote Directory Should Exist With Content  ${target}

-Put Dir With Different Name
+Put Dir To Different Name
     ${target} =  Set Variable  ${USER HOME}/another_dir_name
     Remote Directory Should Not Exist  ${target}
     Put Dir  ${TEXTFILES}   ${target}
     Remote Directory Should Exist With Content  ${target}

-Put Dir With Subdirectories
+Put Dir Including Subdirectories
     ${target} =  Set Variable  ${USER HOME}/new_dir/
     Remote Directory Should Not Exist  ${target}
     Put Dir  ${TEXTFILES}  ${target}  recursive=True
=======================================
--- /atest/put_file.txt Tue Jul 30 02:43:29 2013
+++ /atest/put_file.txt Tue Jul 30 08:47:58 2013
@@ -1,5 +1,4 @@
 *** Settings ***
-Documentation This suite contains test for 'Put File 'keywords These tests use some dummy test files from under the scripts directory.
 Force Tags      pybot   jybot
 Suite Setup     Login As Valid User
 Suite Teardown  Close All Connections
=======================================
--- /src/SSHLibrary/abstractclient.py   Tue Jul 30 03:56:32 2013
+++ /src/SSHLibrary/abstractclient.py   Tue Jul 30 08:47:58 2013
@@ -318,13 +318,19 @@
def get_dir(self, source, destination, path_separator='/', recursive=False):
         remotefiles = []
         localfiles = []
-        subdirs = [os.path.basename(source)]
+        if source.endswith(path_separator):
+            parent_dir = source.split(path_separator)[-2]
+        else:
+            parent_dir = os.path.basename(source)
+        subdirs = [parent_dir]
         for path in subdirs:
             if recursive:
                 [subdirs.append(path_separator.join([path, subdir_name]))
                 for subdir_name in self._listdirs(path)]
             remote_path = path + path_separator + "*"
             local_path = os.path.join(destination, path) + path_separator
+            if source.endswith(path_separator):
+                local_path = local_path.replace(parent_dir, '')
             r, l = self.get_file(remote_path, local_path, path_separator)
             remotefiles.extend(r)
             localfiles.extend(l)
@@ -384,9 +390,9 @@
         for dirpath, _, filenames in os.walk(parent):
             for filename in filenames:
                 local_path = os.path.join(dirpath, filename)
-                if destination.endswith('./'):
+                if destination.endswith('.' + os.path.sep):
                     remote_path = path_separator.join([dirpath, filename])
-                elif destination.endswith('/'):
+                elif destination.endswith(os.path.sep):
                     remote_path = path_separator.join([destination[:-1],
                                                        dirpath,
                                                        filename])

--

--- 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