diff options
Diffstat (limited to 'addons/document_ftp/test/document_ftp_test2.yml')
| -rw-r--r-- | addons/document_ftp/test/document_ftp_test2.yml | 220 |
1 files changed, 220 insertions, 0 deletions
diff --git a/addons/document_ftp/test/document_ftp_test2.yml b/addons/document_ftp/test/document_ftp_test2.yml new file mode 100644 index 00000000000..e9ac2d84582 --- /dev/null +++ b/addons/document_ftp/test/document_ftp_test2.yml @@ -0,0 +1,220 @@ +- + In order to test the document_ftp functionality +- + I open the 8021 port and see for ftp presence there +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_plain_ftp(timeout=2.0) + assert ftp.sock and (ftp.lastresp == '220'), ftp.lastresp +- + I read the list of databases at port 8021 and confirm our db is + there +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_login(cr, uid, self) + assert cr.dbname in ftp.nlst("/") +- + I try to locate the default "Documents" folder in the db. +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_login(cr, uid, self) + ftp.cwd('Documents') +- + I create a "test.txt" file at the server (directly). The file + should have the "abcd" content +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + from cStringIO import StringIO + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + fdata = StringIO('abcd') + ftp.storbinary('STOR test.txt', fdata) +- + I look for the "test.txt" file at the server +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + assert ftp.nlst("test.txt") == ['test.txt'] +- + I check that the content of "test.txt" is "abcd" +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + from cStringIO import StringIO + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + assert te.get_ftp_fulldata(ftp, "test.txt") == 'abcd' +- + I append the string 'defgh' into "test.txt" +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + from cStringIO import StringIO + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + fdata = StringIO('defgh') + ftp.storbinary('APPE test.txt', fdata) +- + I check that the content of "text.txt" is 'abcddefgh' +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + from cStringIO import StringIO + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + assert te.get_ftp_fulldata(ftp, "test.txt") == 'abcddefgh' +- + I try to cd into an non-existing folder 'Not-This' +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + import ftplib + ftp = te.get_ftp_login(cr, uid, self) + try: + ftp.cwd('/Not-This') + assert False, "We should't be able to change here" + except ftplib.error_perm: + pass + except OSError, err: + assert err.errno == 2, err.errno +- + I create a "test2.txt" file through FTP. +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + from cStringIO import StringIO + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + fdata = StringIO('abcd') + ftp.storbinary('STOR test2.txt', fdata) +- + I look for the "test2.txt" file at the server +- + !python {model: ir.attachment }: | + ids = self.search(cr, uid, [('name', '=', 'test2.txt')]) + assert ids +- + I delete the "test2.txt" file using FTP. +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + from cStringIO import StringIO + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + ftp.delete('test2.txt') +- + I check at the server that test2.txt is deleted +- + !python {model: ir.attachment }: | + ids = self.search(cr, uid, [('name', '=', 'test2.txt')]) + assert not ids +- + I create a test2.txt file again. +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + from cStringIO import StringIO + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + fdata = StringIO('abcd') + ftp.storbinary('STOR test2.txt', fdata) +- + I delete the test2.txt from the server (RPC). +- + !delete { model: ir.attachment, id:, search: "[('name','=','test2.txt')]" } +- + I check through FTP that test2.txt does not appear. +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + assert ftp.nlst("test2.txt") == [] +- + I create a "test-name.txt" file +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + from cStringIO import StringIO + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + fdata = StringIO('abcd') + ftp.storbinary('STOR test-name.txt', fdata) +- + I rename the "test-name.txt" file through ftp. +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + ftp.rename("test-name.txt", "test-renamed.txt") +- + I check that test-name.txt has been renamed. +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + from ftplib import error_perm + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + try: + res = ftp.nlst("test-name.txt") + assert res == [] + except error_perm, e: + pass + assert ftp.nlst("test-renamed.txt") == ['test-renamed.txt'] +- + I create a new folder 'Test-Folder2' through FTP +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + ftp.mkd("Test-Folder2") +- + I create a file 'test3.txt' at the 'Test-Folder2' +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + from cStringIO import StringIO + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2') + fdata = StringIO('abcd') + ftp.storbinary('STOR test3.txt', fdata) +- + I try to retrieve test3.txt +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2') + assert ftp.nlst("test3.txt") == ['test3.txt'] +- + I create a new folder, 'Test-Folder3', through FTP + I try to move test3.txt to 'Test-Folder3' +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_folder(cr, uid, self, 'Documents') + ftp.mkd("Test-Folder2") + # TODO move +- + I remove the 'Test-Folder3' +- + I check that test3.txt is removed. +- + I create 200 files through FTP +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + from cStringIO import StringIO + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2') + fdata = StringIO('abcd') + # TODO speed + for i in range(0, 200): + fdata.seek(0) + ftp.storbinary('STOR test-name%s.txt' %i, fdata) +- + I list the 200 files, check speed +- + !python {model: ir.attachment}: | + from document_ftp import test_easyftp as te + ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Test-Folder2') + # TODO speed + assert len(ftp.nlst()) > 200 +- + I read the 200 files, check speed + # TODO +- + I move the 200 files to 'Test-Folder2' + # TODO
\ No newline at end of file |
