Files
odoo_source/addons/document/test/document_test2.yml
T
Olivier Dony c5c88c43c0 [FIX] document: removed dangerous and useless commits
These commits were introduce mostly at revision 
1849.1.1 revid:hmo@tinyerp.com-20081111052750-zqzvr6oaihvt103t
in an attempt to fix an issue with transactions
originating from FTP connections.
This was wrong: the virtual FTP filesystem should
perform its own transaction management for each
operation, just like the RPC layer does it for
each request. Forcing a commit in the business
code during the course of a normal transaction is
totally *forbidden*!
In addition, the FTP layer now properly manages
its transactions, so the commit calls were useless
anyway.

bzr revid: odo@openerp.com-20111130120239-5fcavvpd14w056zb
2011-11-30 13:02:39 +01:00

83 lines
2.5 KiB
YAML

-
In order to test the document management I make sure the default installation has some storage.
-
!assert {model: document.storage, id: storage_default }:
- id != False
-
I make sure the default installation has some root directory.
-
!assert {model: document.directory, id: dir_root}:
- storage_id != False
-
I create a "Testing" folder where all the test data will go.
-
!record {model: document.directory, id: dir_tests }:
name: 'Testing (will be deleted!)'
parent_id: dir_root
-
I create an attachment into the root folder (w. empty fields, test that
defaults work)
-
!record {model: ir.attachment, id: file_test1 }:
name: Test file.txt
-
I delete the attachment from the root folder
-
!python {model: ir.attachment}: |
self.unlink(cr, uid, [ref('file_test1')])
-
I create an attachment into the Testing folder.
-
!record {model: ir.attachment, id: file_test2 }:
name: Test file 2
parent_id: dir_tests
-
I update the attachment with data, namely "abcd"
-
!record {model: ir.attachment, id: file_test2 }:
datas: "YWJjZA==\n"
-
I test that the datas of the attachment are correct
-
!assert {model: ir.attachment, id: file_test2 }:
- datas == "YWJjZA==\n"
- file_size == 4
- file_type == 'text/plain'
-
I rename the attachment.
-
!record {model: ir.attachment, id: file_test2 }:
name: Test renamed 2
-
I search the testing folder for attachments.
-
!python {model: ir.attachment}: |
ids = self.search(cr, uid, [('parent_id.name','=', 'Testing (will be deleted!)'), ('name','=','Test renamed 2')])
assert ids == [ ref("file_test2") ], ids
-
I create an attachment to a 3rd resource, eg. a res.country
-
!record {model: ir.attachment, id: attach_3rd }:
name: 'Country attachment.txt'
parent_id: dir_tests
datas: "Q291bnRyeSBhdHRhY2htZW50IGNvbnRlbnQ=\n"
res_model: res.country
res_id: !eval ref("base.za")
-
I search for the res.country attachment
-
!python {model: ir.attachment}: |
ids = self.search(cr, uid, [('res_model', '=', 'res.country'), ('res_id', '=', ref("base.za"))])
assert ids == [ ref("attach_3rd")], ids
-
I delete the attachments
-
!python {model: ir.attachment}: |
self.unlink(cr, uid, [ref('file_test2')])
self.unlink(cr, uid, [ref('attach_3rd')])
-
I delete the tests folder
-
!python {model: document.directory}: |
self.unlink(cr, uid, [ref('dir_tests')])