summaryrefslogtreecommitdiff
path: root/addons/document_ftp/test/document_ftp_test4.yml
diff options
context:
space:
mode:
Diffstat (limited to 'addons/document_ftp/test/document_ftp_test4.yml')
-rw-r--r--addons/document_ftp/test/document_ftp_test4.yml187
1 files changed, 0 insertions, 187 deletions
diff --git a/addons/document_ftp/test/document_ftp_test4.yml b/addons/document_ftp/test/document_ftp_test4.yml
deleted file mode 100644
index 9b311f64605..00000000000
--- a/addons/document_ftp/test/document_ftp_test4.yml
+++ /dev/null
@@ -1,187 +0,0 @@
--
- 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
--
- I commit (because FTP operations are on different transaction)
--
- !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 commit (because FTP operations are on different transaction)
--
- !python {model: document.directory, id: }: |
- cr.commit()
--
- 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)
- cr.rollback() # restart transaction to see changes (FTP-FS uses its own cursor)
--
- 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 == 'Documents'
- - res_model == 'res.partner'
- - res_id != False
--
- I try to create a file directly under the Partners Testing folder
--
- !python {model: ir.attachment}: |
- from document_ftp import test_easyftp as te
- import ftplib
- from cStringIO import StringIO
- ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Partners Testing')
- fdata = StringIO('abcd')
- try:
- ftp.storbinary('STOR stray.txt', fdata)
- assert False, "We should't be able to create files here"
- except ftplib.error_perm:
- # That's what should happen
- pass
--
- I try to create a folder directly under the Partners Testing folder
--
- !python {model: ir.attachment}: |
- from document_ftp import test_easyftp as te
- import ftplib
- from cStringIO import StringIO
- ftp = te.get_ftp_folder(cr, uid, self, 'Documents/Partners Testing')
- try:
- ftp.mkd('Weird folder')
- assert False, "We should't be able to create folders here"
- except ftplib.error_perm:
- # That's what should happen
- pass
--
- I check that all/Partner1 also has the file
-- |
- Bonus Piste:
- I create a 'Partner3' under 'all'
-
--
- I delete "pat1-dynamic.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/Partners Testing/Pat 1/Partners of Test/Partner 1')
- ftp.delete('pat1-dynamic.txt')
- ftp.close()
- cr.rollback() # restart transaction to see changes (FTP-FS uses its own cursor)
-
--
- I delete the Partners Testing folder, "File of pat1" file, Partner and Partner category.
--
- !python {model: document.directory}: |
- attach_pool = self.pool.get('ir.attachment')
- partner_categ_pool = self.pool.get('res.partner.category')
- partner_pool = self.pool.get('res.partner')
-
- self.unlink(cr, uid, [ref('dir_tests2')])
- self.unlink(cr, uid, [ref('dir_respart1')])
- attach_pool.unlink(cr, uid, [ref('file_test1')])
- partner_categ_pool.unlink(cr, uid, [ref('tpat_categ_none')])
- partner_categ_pool.unlink(cr, uid, [ref('tpat_categ_pat1')])
- partner_categ_pool.unlink(cr, uid, [ref('tpat_categ_all')])
- partner_pool.unlink(cr, uid, [ref('tpartner1')])
- partner_pool.unlink(cr, uid, [ref('tpartner_2')])
- cr.commit() #required because all the operations via FTP were committed
-