summaryrefslogtreecommitdiff
path: root/addons/document_ftp/test
diff options
context:
space:
mode:
Diffstat (limited to 'addons/document_ftp/test')
-rw-r--r--addons/document_ftp/test/document_ftp_test2.yml220
-rw-r--r--addons/document_ftp/test/document_ftp_test3.yml82
-rw-r--r--addons/document_ftp/test/document_ftp_test4.yml120
3 files changed, 422 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
diff --git a/addons/document_ftp/test/document_ftp_test3.yml b/addons/document_ftp/test/document_ftp_test3.yml
new file mode 100644
index 00000000000..2161c1421da
--- /dev/null
+++ b/addons/document_ftp/test/document_ftp_test3.yml
@@ -0,0 +1,82 @@
+-
+ In order to check international character functionality
+-
+ !python {model: ir.attachment}: |
+ from document_ftp import test_easyftp as te
+ ftp = te.get_plain_ftp(timeout=1.0)
+-
+ I create in the server a folder called 'Δοκιμαστικός Φάκελλος'
+-
+ !record {model: document.directory, id: dir_itests }:
+ name: 'Δοκιμαστικός Φάκελλος'
+ parent_id: document.dir_root
+-
+ And then I create another folder, under it, through FTP
+-
+ !python {model: ir.attachment}: |
+ cr.commit()
+ from document_ftp import test_easyftp as te
+ ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Δοκιμαστικός Φάκελλος')
+ ftp.mkd("Φάκελλος από κάτω")
+-
+ I check that this folder exists at the server
+-
+ !assert {model: document.directory, id: , search: "[('name','=','Φάκελλος από κάτω')]" }:
+ - parent_id != False
+-
+ I login with FTP and check that 'Δοκιμαστικός Φάκελλος' is there
+-
+ !python {model: ir.attachment}: |
+ from document_ftp import test_easyftp as te
+ ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Δοκιμαστικός Φάκελλος/Φάκελλος από κάτω')
+-
+ I create a file named 'Δοκιμή' into that folder
+-
+ !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('κείμενο με utf-8')
+ ftp.storbinary('STOR Δοκιμή.txt', fdata)
+-
+ I remove the 'Δοκιμή.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('Δοκιμή.txt')
+-
+ I rename 'Φάκελλος από κάτω' into 'άλλος'
+-
+ !python {model: ir.attachment}: |
+ from document_ftp import test_easyftp as te
+ ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Δοκιμαστικός Φάκελλος')
+ ftp.rename("Φάκελλος από κάτω", "άλλος")
+-
+ I place a file 'file Φ3' in 'άλλος'
+-
+ !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('κι άλλο κείμενο')
+ ftp.storbinary('STOR file Φ3.txt', fdata)
+-
+ I rename the file into file+range(1..200) (large filename)
+-
+ !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/Δοκιμαστικός Φάκελλος/άλλος')
+ vuvuzela = 'b'+''.join('z' * 200)+'!'
+ ftp.rename("file Φ3.txt", vuvuzela)
+-
+ I delete the file with the large name
+-
+ !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/Δοκιμαστικός Φάκελλος/άλλος')
+ vuvuzela = 'b'+''.join('z' * 200)+'!'
+ ftp.delete(vuvuzela)
diff --git a/addons/document_ftp/test/document_ftp_test4.yml b/addons/document_ftp/test/document_ftp_test4.yml
new file mode 100644
index 00000000000..9c3baed0844
--- /dev/null
+++ b/addons/document_ftp/test/document_ftp_test4.yml
@@ -0,0 +1,120 @@
+-
+ In order to check dynamic folder functionality of document + FTP
+-
+ !python {model: ir.attachment}: |
+ from document_ftp import test_easyftp as te
+ ftp = te.get_plain_ftp(timeout=1.0)
+- |
+ I create two partners 'Partner1' and 'Partner2'.
+ I create three partner categories: 'none', 'pat1' and 'all'
+ I attach Partner1 to pat1, Partner1+Partner2 to 'all'
+-
+ !record {model: res.partner.category, id: tpat_categ_none }:
+ name: 'No partners'
+-
+ !record {model: res.partner.category, id: tpat_categ_pat1 }:
+ name: 'Pat 1'
+-
+ !record {model: res.partner.category, id: tpat_categ_all }:
+ name: 'All Partner1+2'
+-
+ !record {model: res.partner, id: tpartner1 }:
+ name: Partner 1
+ category_id:
+ - tpat_categ_pat1
+ - tpat_categ_all
+-
+ !record {model: res.partner, id: tpartner_2 }:
+ name: 'Partner 2'
+ category_id:
+ - tpat_categ_all
+-
+ I create a resource folder of partners, by the (none, pat1, all)
+ categories.
+-
+ !record {model: document.directory, id: dir_tests2 }:
+ name: Partners Testing
+ parent_id: document.dir_root
+ type: ressource
+ ressource_type_id: base.model_res_partner_category
+ domain: [] # TODO
+-
+ I commit (because FTP operations are on different transaction)
+-
+ !python {model: document.directory, id: }: |
+ cr.commit()
+-
+ I browse through ftp in the resource folder, checking that three
+ categories are there.
+-
+ !python {model: ir.attachment}: |
+ from document_ftp import test_easyftp as te
+ ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Partners Testing')
+ dirs = ftp.nlst()
+ for dir in [ 'All Partner1+2', 'No partners', 'Pat 1' ]:
+ assert dir in dirs, "Dir %s not in folder" % dir
+-
+ I create a 'partners' folder by the first resource one.
+-
+ !record {model: document.directory, id: dir_respart1 }:
+ name: Partners of Test
+ parent_id: dir_tests2
+ type: ressource
+ ressource_type_id: base.model_res_partner
+ domain: "[('category_id','in',[active_id])]"
+ ressource_parent_type_id : base.model_res_partner_category
+-
+ !python {model: document.directory, id: }: |
+ cr.commit()
+-
+ I check through FTP that the correct partners are listed at each
+ 'partners' folder.
+-
+ !python {model: ir.attachment}: |
+ from document_ftp import test_easyftp as te
+ ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Partners Testing')
+ correct = { 'All Partner1+2': [ 'Partner 1', 'Partner 2' ],
+ 'No partners': [],
+ 'Pat 1': ['Partner 1',] }
+ for dir in correct:
+ res = ftp.nlst(dir+'/Partners of Test')
+ assert res == correct[dir], "Dir %s falsely contains %s" %(dir, res)
+-
+ I create an ir.attachment, attached (not related) to Partner1
+-
+ !record {model: ir.attachment, id: file_test1 }:
+ name: File of pat1
+ res_model: res.partner
+ res_id: !eval ref("tpartner1")
+-
+ I check that pat1/Partner1 folder has the file.
+ I check that all/Partner1 folder has the file
+-
+ !python {model: ir.attachment}: |
+ from document_ftp import test_easyftp as te
+ ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Partners Testing')
+ dirs = [ 'All Partner1+2', 'Pat 1' ]
+ for dir in dirs:
+ res = ftp.nlst(dir+'/Partners of Test/Partner 1')
+ assert 'File of pat1' in res, "Dir %s contains only %s" %(dir, res)
+-
+ I place a file at the 'pat1'/Partner1 folder, 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/Partners Testing/Pat 1/Partners of Test/Partner 1')
+ fdata = StringIO('abcd')
+ ftp.storbinary('STOR pat1-dynamic.txt', fdata)
+-
+ I check at the server that the file is attached to Partner1
+-
+ !assert {model: ir.attachment, id: , search: "[('name','=','pat1-dynamic.txt')]" }:
+ - parent_id.name == 'Partners of Test'
+ - res_model == 'res.partner'
+ - res_id != False
+-
+ I check that all/Partner1 also has the file
+- |
+ Bonus Piste:
+ I create a 'Partner3' under 'all'