forked from kowalpy/Robot-Framework-FTP-Library
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ftpLibraryExample.txt
110 lines (105 loc) · 4.6 KB
/
ftpLibraryExample.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
*** Settings ***
Library FtpLibrary
Library Collections
*** Variables ***
${public_address} speedtest.tele2.net
${public_file_name} 1KB.zip
${local_ftp_addr_1} 10.1.4.21
${local_ftp_addr_2} 10.1.4.120
${local_ftp_addr_3} 10.1.4.87
${fake_ftp_addr} 10.244.17.36
${user_1} marcin
${pass_1} marcin
${user_2} marcin
${pass_2} marcin
${user_3} marcin
${pass_3} marcin
${test_file_name} test.txt
*** Test Cases ***
the_simplest_example_public_ftp
comment Public FTP server IP address taken from http://stackoverflow.com/questions/7968703/is-there-a-public-ftp-server-to-test-upload-and-download
ftp connect ${public_address}
@{dirResult}= dir
${pwdMsg}= pwd
download file ${public_file_name}
ftp close
get_connections
[Documentation] Testing new keyword "get all ftp connections"
${connections}= get all ftp connections
ftp connect ${local_ftp_addr_1} ${user_1} ${pass_1}
ftp connect ${local_ftp_addr_2} ${user_2} ${pass_2} connId=secondConn
ftp connect ${local_ftp_addr_3} ${user_3} ${pass_3} connId=thirdConn
${connections}= get all ftp connections
@{connectionKeys}= get dictionary keys ${connections}
@{connectionValues}= get dictionary values ${connections}
: FOR ${k} IN @{connectionKeys}
\ Log ${k}
: FOR ${c} IN @{connectionValues}
\ Log ${c}
ftp close
ftp close secondConn
ftp close thirdConn
${connections}= get all ftp connections
full_test_3_connections
[Documentation] Testing all keywords in the library in 3 different parallel connections.
ftp connect ${local_ftp_addr_1} ${user_1} ${pass_1}
ftp connect ${local_ftp_addr_2} ${user_2} ${pass_2} connId=secondConn
ftp connect ${local_ftp_addr_3} ${user_3} ${pass_3} connId=thirdConn
${newDir1}= set variable w_szczebrzeszynie
${newDir2}= set variable chrzaszcz_brzmi
${newDir3}= set variable w_trzcinie
${newFIle1}= set variable stol_z_powylamywanymi_nogami
${newFIle2}= set variable suchaSzosaSaszaSzedl
${welcomeMsg}= get welcome
Log ${welcomeMsg}
${welcomeMsg}= get welcome connId=secondConn
Log ${welcomeMsg}
${welcomeMsg}= get welcome connId=thirdConn
Log ${welcomeMsg}
${pwdMsg}= pwd
Log ${pwdMsg}
Log mkd
mkd ${newDir2} secondConn
Log dir
@{dirResult}= dir secondConn
Log ${dirResult}
rmd ${newDir2} secondConn
@{dirResult}= dir secondConn
Log ${dirResult}
send cmd HELP
mkd ${newDir1} thirdConn
cwd ${newDir1} thirdConn
${currDir}= pwd thirdConn
upload file ${test_file_name} connId=thirdConn
upload file ${test_file_name} ${newFIle2} thirdConn
dir thirdConn
rename ${test_file_name} ${newFIle1} thirdConn
dir thirdConn
comment ${size}= size ${newFIle1} thirdConn
comment Log ${size}
download file ${newFIle1} connId=thirdConn
download file ${newFIle2} connId=thirdConn
download file ${newFIle1} tmp connId=thirdConn
download file ${newFIle2} tmp connId=thirdConn
delete ${newFIle1} thirdConn
delete ${newFIle2} thirdConn
dir thirdConn
pwd secondConn
pwd thirdConn
ftp close
ftp close secondConn
ftp close thirdConn
negative_tests
[Documentation] Testing handling of exceptions
ftp connect ${local_ftp_addr_1} ${user_1} ${pass_1} connId=newConn
${passed}= Run Keyword And Return Status pwd connId=newConn2
Run Keyword Unless ${passed} Log Fail as expected
${passed2}= Run Keyword And Return Status ftp connect ${local_ftp_addr_1} ${user_1} ${pass_1} connId=newConn
... # already existing connection ID
Run Keyword Unless ${passed2} Log Fail as expected
${passed3}= Run Keyword And Return Status pwd connId=newConn8 # not existing connection ID
Run Keyword Unless ${passed3} Log Fail as expected
${passed4}= Run Keyword And Return Status ftp connect ${fake_ftp_addr} ${user_1} ${pass_1} # wrong IP address
Run Keyword Unless ${passed4} Log Fail as expected
${passed5}= Run Keyword And Return Status upload file shagdfqfcrtcfjwgakwrj connId=newConn # not existing file
Run Keyword Unless ${passed5} Log Fail as expected