2 In order to test the document_ftp functionality
4 I open the 8021 port and see for ftp presence there
6 !python {model: ir.attachment}: |
7 from document_ftp import test_easyftp as te
8 ftp = te.get_plain_ftp()
9 assert ftp.sock and (ftp.lastresp == '220'), ftp.lastresp
11 I read the list of databases at port 8021 and confirm our db is
14 !python {model: ir.attachment}: |
15 from document_ftp import test_easyftp as te
16 ftp = te.get_ftp_login(cr, uid, self)
17 assert cr.dbname in ftp.nlst("/")
19 I try to locate the default "Documents" folder in the db.
21 !python {model: ir.attachment}: |
22 from document_ftp import test_easyftp as te
23 ftp = te.get_ftp_login(cr, uid, self)
26 I create a "test.txt" file at the server (directly). The file
27 should have the "abcd" content
29 !python {model: ir.attachment}: |
30 from document_ftp import test_easyftp as te
31 from cStringIO import StringIO
32 ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
33 fdata = StringIO('abcd')
34 ftp.storbinary('STOR test.txt', fdata)
36 I look for the "test.txt" file at the server
38 !python {model: ir.attachment}: |
39 from document_ftp import test_easyftp as te
40 ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
41 assert ftp.nlst("test.txt") == ['test.txt']
43 I check that the content of "test.txt" is "abcd"
45 !python {model: ir.attachment}: |
46 from document_ftp import test_easyftp as te
47 from cStringIO import StringIO
48 ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
49 assert te.get_ftp_fulldata(ftp, "test.txt") == 'abcd'
51 I append the string 'defgh' into "test.txt"
53 !python {model: ir.attachment}: |
54 from document_ftp import test_easyftp as te
55 from cStringIO import StringIO
56 ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
57 fdata = StringIO('defgh')
58 ftp.storbinary('APPE test.txt', fdata)
60 I check that the content of "text.txt" is 'abcddefgh'
62 !python {model: ir.attachment}: |
63 from document_ftp import test_easyftp as te
64 from cStringIO import StringIO
65 ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
66 assert te.get_ftp_fulldata(ftp, "test.txt") == 'abcddefgh'
68 I try to cd into an non-existing folder 'Not-This'
70 !python {model: ir.attachment}: |
71 from document_ftp import test_easyftp as te
72 ftp = te.get_ftp_login(cr, uid, self)
75 assert False, "We should't be able to change here"
77 assert err.errno == 2, err.errno
79 I create a "test2.txt" file through FTP.
81 !python {model: ir.attachment}: |
82 from document_ftp import test_easyftp as te
83 from cStringIO import StringIO
84 ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
85 fdata = StringIO('abcd')
86 ftp.storbinary('STOR test2.txt', fdata)
88 I look for the "test2.txt" file at the server
90 !python {model: ir.attachment }: |
91 ids = self.search(cr, uid, [('name', '=', 'test2.txt')])
94 I delete the "test2.txt" file using FTP.
96 !python {model: ir.attachment}: |
97 from document_ftp import test_easyftp as te
98 from cStringIO import StringIO
99 ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
100 ftp.delete('test2.txt')
102 I check at the server that test2.txt is deleted
104 !python {model: ir.attachment }: |
105 ids = self.search(cr, uid, [('name', '=', 'test2.txt')])
108 I create a test2.txt file again.
110 !python {model: ir.attachment}: |
111 from document_ftp import test_easyftp as te
112 from cStringIO import StringIO
113 ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
114 fdata = StringIO('abcd')
115 ftp.storbinary('STOR test2.txt', fdata)
117 I delete the test2.txt from the server (RPC).
119 !delete { model: ir.attachment, id:, search: "[('name','=','test2.txt')]" }
121 I check through FTP that test2.txt does not appear.
123 !python {model: ir.attachment}: |
124 from document_ftp import test_easyftp as te
125 ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
126 assert ftp.nlst("test2.txt") == []
128 I create a "test-name.txt" file
130 !python {model: ir.attachment}: |
131 from document_ftp import test_easyftp as te
132 from cStringIO import StringIO
133 ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
134 fdata = StringIO('abcd')
135 ftp.storbinary('STOR test-name.txt', fdata)
137 I rename the "test-name.txt" file through ftp.
139 !python {model: ir.attachment}: |
140 from document_ftp import test_easyftp as te
141 ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
142 ftp.rename("test-name.txt", "test-renamed.txt")
144 I check that test-name.txt has been renamed.
146 !python {model: ir.attachment}: |
147 from document_ftp import test_easyftp as te
148 from ftplib import error_perm
149 ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
151 res = ftp.nlst("test-name.txt")
153 except error_perm, e:
155 assert ftp.nlst("test-renamed.txt") == ['test-renamed.txt']
157 I create a new folder 'Test-Folder2' through FTP
159 !python {model: ir.attachment}: |
160 from document_ftp import test_easyftp as te
161 ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
162 ftp.mkd("Test-Folder2")
164 I create a file 'test3.txt' at the 'Test-Folder2'
166 !python {model: ir.attachment}: |
167 from document_ftp import test_easyftp as te
168 from cStringIO import StringIO
169 ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2')
170 fdata = StringIO('abcd')
171 ftp.storbinary('STOR test3.txt', fdata)
173 I try to retrieve test3.txt
175 !python {model: ir.attachment}: |
176 from document_ftp import test_easyftp as te
177 ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2')
178 assert ftp.nlst("test3.txt") == ['test3.txt']
180 I create a new folder, 'Test-Folder3', through FTP
181 I try to move test3.txt to 'Test-Folder3'
183 !python {model: ir.attachment}: |
184 from document_ftp import test_easyftp as te
185 ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
186 ftp.mkd("Test-Folder2")
189 I remove the 'Test-Folder3'
191 I check that test3.txt is removed.
193 I create 1000 files through FTP
195 !python {model: ir.attachment}: |
196 from document_ftp import test_easyftp as te
197 from cStringIO import StringIO
198 ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2')
199 fdata = StringIO('abcd')
201 for i in range(0, 1000):
203 ftp.storbinary('STOR test-name%s.txt' %i, fdata)
205 I list the 1000 files, check speed
207 !python {model: ir.attachment}: |
208 from document_ftp import test_easyftp as te
209 ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2')
211 assert len(ftp.nlst()) > 1000
213 I read the 1000 files, check speed
216 I move the 1000 files to 'Test-Folder2'