Merge pull request #417 from gurneyalex/7.0-fix_1311004_account_move_line_index-afe
[odoo/odoo.git] / addons / document_ftp / test / document_ftp_test2.yml
1 -
2     In order to test the document_ftp functionality
3 -
4     I open the 8021 port and see for ftp presence there
5 -
6     !python {model: ir.attachment}: |
7         from document_ftp import test_easyftp as te
8         ftp = te.get_plain_ftp(timeout=2.0)
9         assert ftp.sock and (ftp.lastresp == '220'), ftp.lastresp
10         ftp.close()
11 -
12     I read the list of databases at port 8021 and confirm our db is
13     there
14 -
15     !python {model: ir.attachment}: |
16         from document_ftp import test_easyftp as te
17         ftp = te.get_ftp_login(cr, uid, self)
18         assert cr.dbname in ftp.nlst("/")
19         ftp.close()
20 -
21     I try to locate the default "Documents" folder in the db.
22 -
23     !python {model: ir.attachment}: |
24         from document_ftp import test_easyftp as te
25         ftp = te.get_ftp_login(cr, uid, self)
26         ftp.cwd('Documents')
27         ftp.close()
28 -
29     I create a "test.txt" file at the server (directly). The file
30     should have the "abcd" content
31 -
32     !python {model: ir.attachment}: |
33         from document_ftp import test_easyftp as te
34         from cStringIO import StringIO
35         ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
36         fdata = StringIO('abcd')
37         ftp.storbinary('STOR test.txt', fdata)
38         ftp.close()
39 -
40     I look for the "test.txt" file at the server
41 -
42     !python {model: ir.attachment}: |
43         from document_ftp import test_easyftp as te
44         ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
45         assert ftp.nlst("test.txt") == ['test.txt']
46         ftp.close()
47 -
48     I check that the content of "test.txt" is "abcd"
49 -
50     !python {model: ir.attachment}: |
51         from document_ftp import test_easyftp as te
52         from cStringIO import StringIO
53         ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
54         gotdata = te.get_ftp_fulldata(ftp, "test.txt")
55         ftp.close()
56         assert gotdata == 'abcd', 'Data: %r' % gotdata
57 -
58     I append the string 'defgh' to "test.txt"
59 -
60     !python {model: ir.attachment}: |
61         from document_ftp import test_easyftp as te
62         from cStringIO import StringIO
63         ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
64         fdata = StringIO('defgh')
65         ftp.storbinary('APPE test.txt', fdata)
66         ftp.close()
67 -
68     I check that the content of "text.txt" is 'abcddefgh'
69 -
70     !python {model: ir.attachment}: |
71         from document_ftp import test_easyftp as te
72         from cStringIO import StringIO
73         ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
74         gotdata = te.get_ftp_fulldata(ftp, "test.txt")
75         ftp.close()
76         assert gotdata == 'abcddefgh', 'Data: %r' % gotdata
77 -
78     I try to cd into an non-existing folder 'Not-This'
79 -
80     !python {model: ir.attachment}: |
81         from document_ftp import test_easyftp as te
82         import ftplib
83         ftp = te.get_ftp_login(cr, uid, self)
84         try:
85             ftp.cwd('/Not-This')
86             assert False, "We should't be able to change here"
87         except ftplib.error_perm:
88             pass
89         except OSError, err:
90             ftp.close()
91             assert err.errno == 2, err.errno
92         ftp.close()
93 -
94     I create a "test2.txt" file through FTP.
95 -
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         fdata = StringIO('abcd')
101         ftp.storbinary('STOR test2.txt', fdata)
102         ftp.close()
103 -
104     I look for the "test2.txt" file at the server
105 -
106     !python {model: ir.attachment }: |
107         cr.rollback() # restart transaction to see changes (FTP-FS uses its own cursor)
108         ids = self.search(cr, uid, [('name', '=', 'test2.txt')])
109         assert ids, "No test2.txt file found."
110 -
111     I delete the "test2.txt" file using FTP.
112 -
113     !python {model: ir.attachment}: |
114         from document_ftp import test_easyftp as te
115         from cStringIO import StringIO
116         ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
117         ftp.delete('test2.txt')
118         ftp.close()
119 -
120     I check at the server that test2.txt is deleted
121 -
122     !python {model: ir.attachment }: |
123         cr.rollback() # restart transaction to see changes (FTP-FS uses its own cursor)
124         ids = self.search(cr, uid, [('name', '=', 'test2.txt')])
125         assert not ids, "test2.txt file can still be found."
126 -
127     I create a test2.txt file again.
128 -
129     !python {model: ir.attachment}: |
130         from document_ftp import test_easyftp as te
131         from cStringIO import StringIO
132         ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
133         fdata = StringIO('abcd')
134         ftp.storbinary('STOR test2.txt', fdata)
135         ftp.close()
136         cr.rollback() # restart transaction to see changes (FTP-FS uses its own cursor)
137 -
138     I delete the test2.txt from the server (RPC).
139 -
140     !delete { model: ir.attachment, id:,  search: "[('name','=','test2.txt')]" }
141 -
142     I also commit, because ftp would run in a different transaction.
143 -
144     !python {model: ir.attachment}: |
145         cr.commit()
146 -
147     I check through FTP that test2.txt does not appear.
148 -
149     !python {model: ir.attachment}: |
150         from document_ftp import test_easyftp as te
151         import ftplib
152         ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
153         try:
154             nlst_result = ftp.nlst("test2.txt")
155         except ftplib.error_perm: # 550 error: 'path not exists'
156             nlst_result = []
157         assert "test2.txt" not in nlst_result, "Files: %r" % nlst_result
158         ftp.close()
159 -
160     I create a "test-name.txt" file
161 -
162     !python {model: ir.attachment}: |
163         from document_ftp import test_easyftp as te
164         from cStringIO import StringIO
165         ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
166         fdata = StringIO('abcd')
167         ftp.storbinary('STOR test-name.txt', fdata)
168         ftp.close()
169 -
170     I rename the "test-name.txt" file through ftp.
171 -
172     !python {model: ir.attachment}: |
173         from document_ftp import test_easyftp as te
174         ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
175         ftp.rename("test-name.txt", "test-renamed.txt")
176         ftp.close()
177 -
178     I check that test-name.txt has been renamed.
179 -
180     !python {model: ir.attachment}: |
181         from document_ftp import test_easyftp as te
182         from ftplib import error_perm
183         ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
184         try:
185             res = ftp.nlst("test-name.txt")
186             assert res == [], "File has not been renamed!"
187         except error_perm, e:
188             pass
189         assert ftp.nlst("test-renamed.txt") == ['test-renamed.txt']
190         ftp.close()
191 -
192     I create a new folder 'Test-Folder2' through FTP
193 -
194     !python {model: ir.attachment}: |
195         from document_ftp import test_easyftp as te
196         ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
197         ftp.mkd("Test-Folder2")
198         ftp.close()
199 -
200     I create a file 'test3.txt' at the 'Test-Folder2'
201 -
202     !python {model: ir.attachment}: |
203         from document_ftp import test_easyftp as te
204         from cStringIO import StringIO
205         ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2')
206         fdata = StringIO('abcd')
207         ftp.storbinary('STOR test3.txt', fdata)
208         ftp.close()
209 -
210     I try to retrieve test3.txt
211 -
212     !python {model: ir.attachment}: |
213         from document_ftp import test_easyftp as te
214         ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2')
215         assert ftp.nlst("test3.txt") == ['test3.txt'], "File test3.txt is not there!"
216         ftp.close()
217 -
218     I create a new folder, 'Test-Folder3', through FTP
219     I try to move test3.txt to 'Test-Folder3'
220 -
221     !python {model: ir.attachment}: |
222         from document_ftp import test_easyftp as te
223         ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
224         ftp.mkd("Test-Folder3")
225         ftp.close()
226         # TODO move
227 -
228     I remove the 'Test-Folder3'
229 -
230     !python {model: ir.attachment}: |
231         from document_ftp import test_easyftp as te
232         ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
233         ftp.rmd("Test-Folder3")
234         ftp.close()
235 -
236     I check that test3.txt is removed.
237 -
238     I create 5 files through FTP
239 -
240     !python {model: ir.attachment}: |
241         from document_ftp import test_easyftp as te
242         from cStringIO import StringIO
243         ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2')
244         fdata = StringIO('abcd')
245         for i in range(0, 5):
246             fdata.seek(0)
247             ftp.storbinary('STOR test-name%s.txt' %i, fdata)
248         ftp.close()
249 -
250     I list the 5 files, check speed
251 -
252     !python {model: ir.attachment}: |
253         from document_ftp import test_easyftp as te
254         ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2')
255         assert len(ftp.nlst()) >= 5, "We haven't managed to store 5 files!"
256 -
257     I read the 5 files, check speed
258 -
259     I move the 5 files to 'Test-Folder2'
260 -
261     I delete the 5 files
262 -
263     !python {model: ir.attachment}: |
264         from document_ftp import test_easyftp as te
265         from cStringIO import StringIO
266         ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2')
267         ftp.delete('test3.txt')
268         for i in range(0, 5):
269             ftp.delete('test-name%s.txt' %i)
270         ftp.close()
271  
272 -
273     I delete the "test.txt" and "test-renamed.txt" file        
274 -
275     !python {model: ir.attachment}: |
276         from document_ftp import test_easyftp as te
277         from cStringIO import StringIO
278         ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
279         ftp.delete('test.txt')
280         ftp.delete('test-renamed.txt')
281         ftp.close()
282 -
283     I remove the 'Test-Folder2'
284 -
285     !python {model: ir.attachment}: |
286         from document_ftp import test_easyftp as te
287         ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
288         ftp.rmd("Test-Folder2")
289         ftp.close()