Files
odoo_source/addons/document_ftp/test/document_ftp_test4.yml
T
P. Christeas 8ed519b800 Doc ftp: Fix yaml test to follow expected behaviour
The document.directory has the "resource_find_all" flag, which now
defaults to True and means that a new doc in a resource folder will
have the *root* Documents as a parent. Fix the test to expect that
behaviour.

bzr revid: p_christ@hol.gr-20100828141852-pyvd24rh1rptqf5f
2010-08-28 17:18:52 +03:00

121 lines
4.2 KiB
YAML

-
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 == 'Documents'
- res_model == 'res.partner'
- res_id != False
-
I check that all/Partner1 also has the file
- |
Bonus Piste:
I create a 'Partner3' under 'all'