summaryrefslogtreecommitdiff
path: root/addons/document_ftp/test/document_ftp_test2.yml
diff options
context:
space:
mode:
Diffstat (limited to 'addons/document_ftp/test/document_ftp_test2.yml')
-rw-r--r--addons/document_ftp/test/document_ftp_test2.yml289
1 files changed, 0 insertions, 289 deletions
diff --git a/addons/document_ftp/test/document_ftp_test2.yml b/addons/document_ftp/test/document_ftp_test2.yml
deleted file mode 100644
index ce8e25906d2..00000000000
--- a/addons/document_ftp/test/document_ftp_test2.yml
+++ /dev/null
@@ -1,289 +0,0 @@
--
- 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
- ftp.close()
--
- 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("/")
- ftp.close()
--
- 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')
- ftp.close()
--
- 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)
- ftp.close()
--
- 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']
- ftp.close()
--
- 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')
- gotdata = te.get_ftp_fulldata(ftp, "test.txt")
- ftp.close()
- assert gotdata == 'abcd', 'Data: %r' % gotdata
--
- I append the string 'defgh' to "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)
- ftp.close()
--
- 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')
- gotdata = te.get_ftp_fulldata(ftp, "test.txt")
- ftp.close()
- assert gotdata == 'abcddefgh', 'Data: %r' % gotdata
--
- 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:
- ftp.close()
- assert err.errno == 2, err.errno
- ftp.close()
--
- 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)
- ftp.close()
--
- I look for the "test2.txt" file at the server
--
- !python {model: ir.attachment }: |
- cr.rollback() # restart transaction to see changes (FTP-FS uses its own cursor)
- ids = self.search(cr, uid, [('name', '=', 'test2.txt')])
- assert ids, "No test2.txt file found."
--
- 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')
- ftp.close()
--
- I check at the server that test2.txt is deleted
--
- !python {model: ir.attachment }: |
- cr.rollback() # restart transaction to see changes (FTP-FS uses its own cursor)
- ids = self.search(cr, uid, [('name', '=', 'test2.txt')])
- assert not ids, "test2.txt file can still be found."
--
- 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)
- ftp.close()
- cr.rollback() # restart transaction to see changes (FTP-FS uses its own cursor)
--
- I delete the test2.txt from the server (RPC).
--
- !delete { model: ir.attachment, id:, search: "[('name','=','test2.txt')]" }
--
- I also commit, because ftp would run in a different transaction.
--
- !python {model: ir.attachment}: |
- cr.commit()
--
- I check through FTP that test2.txt does not appear.
--
- !python {model: ir.attachment}: |
- from document_ftp import test_easyftp as te
- import ftplib
- ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
- try:
- nlst_result = ftp.nlst("test2.txt")
- except ftplib.error_perm: # 550 error: 'path not exists'
- nlst_result = []
- assert "test2.txt" not in nlst_result, "Files: %r" % nlst_result
- ftp.close()
--
- 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)
- ftp.close()
--
- 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")
- ftp.close()
--
- 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 == [], "File has not been renamed!"
- except error_perm, e:
- pass
- assert ftp.nlst("test-renamed.txt") == ['test-renamed.txt']
- ftp.close()
--
- 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")
- ftp.close()
--
- 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)
- ftp.close()
--
- 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'], "File test3.txt is not there!"
- ftp.close()
--
- 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-Folder3")
- ftp.close()
- # TODO move
--
- I remove the 'Test-Folder3'
--
- !python {model: ir.attachment}: |
- from document_ftp import test_easyftp as te
- ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
- ftp.rmd("Test-Folder3")
- ftp.close()
--
- I check that test3.txt is removed.
--
- I create 5 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')
- for i in range(0, 5):
- fdata.seek(0)
- ftp.storbinary('STOR test-name%s.txt' %i, fdata)
- ftp.close()
--
- I list the 5 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')
- assert len(ftp.nlst()) >= 5, "We haven't managed to store 5 files!"
--
- I read the 5 files, check speed
--
- I move the 5 files to 'Test-Folder2'
--
- I delete the 5 files
--
- !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')
- ftp.delete('test3.txt')
- for i in range(0, 5):
- ftp.delete('test-name%s.txt' %i)
- ftp.close()
-
--
- I delete the "test.txt" and "test-renamed.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')
- ftp.delete('test.txt')
- ftp.delete('test-renamed.txt')
- ftp.close()
--
- I remove the 'Test-Folder2'
--
- !python {model: ir.attachment}: |
- from document_ftp import test_easyftp as te
- ftp = te.get_ftp_folder(cr, uid, self, 'Documents')
- ftp.rmd("Test-Folder2")
- ftp.close()