[IMP] use const SUPERUSER_ID insteand of int 1
[odoo/odoo.git] / addons / document / test / document_test2.yml
1 -
2     In order to test the document management I make sure the default installation has some storage.
3 -
4     !assert {model: document.storage, id: storage_default }:
5       - id != False
6 -
7     I make sure the default installation has some root directory.
8 -
9     !assert {model: document.directory, id: dir_root}:
10       - storage_id != False
11 -
12     I create a "Testing" folder where all the test data will go.
13 -
14     !record {model: document.directory, id: dir_tests }:
15         name: 'Testing (will be deleted!)'
16         parent_id: dir_root
17 -
18     I create an attachment into the root folder (w. empty fields, test that
19     defaults work)
20 -
21     !record {model: ir.attachment, id: file_test1 }:
22         name: Test file.txt
23 -
24     I delete the attachment from the root folder
25 -
26     !python {model: ir.attachment}: |
27      self.unlink(cr, uid, [ref('file_test1')])
28 -
29     I create an attachment into the Testing folder.
30 -
31     !record {model: ir.attachment, id: file_test2 }:
32         name: Test file 2
33         parent_id: dir_tests
34 -
35     I update the attachment with data, namely "abcd"
36 -
37     !record {model: ir.attachment, id: file_test2 }:
38         datas: "YWJjZA==\n"
39 -
40     I test that the datas of the attachment are correct
41 -
42     !assert {model: ir.attachment, id: file_test2 }:
43         - datas == "YWJjZA==\n"
44         - file_size == 4
45         - file_type == 'text/plain'
46 -
47     I rename the attachment.
48 -
49     !record {model: ir.attachment, id: file_test2 }:
50         name: Test renamed 2
51 -
52     I search the testing folder for attachments.
53 -
54     !python {model: ir.attachment}: |
55         ids = self.search(cr, uid, [('parent_id.name','=', 'Testing (will be deleted!)'), ('name','=','Test renamed 2')])
56         assert ids == [ ref("file_test2") ], ids
57 -
58     I create an attachment to a 3rd resource, eg. a res.country
59 -
60     !record {model: ir.attachment, id: attach_3rd }:
61         name: 'Country attachment.txt'
62         parent_id: dir_tests
63         datas: "Q291bnRyeSBhdHRhY2htZW50IGNvbnRlbnQ=\n"
64         res_model: res.country
65         res_id: !eval ref("base.za")
66 -
67     I search for the res.country attachment
68 -
69     !python {model: ir.attachment}: |
70         ids = self.search(cr, uid, [('res_model', '=', 'res.country'), ('res_id', '=', ref("base.za"))])
71         assert ids == [ ref("attach_3rd")], ids
72 -
73     I delete the attachments
74 -
75     !python {model: ir.attachment}: |
76      self.unlink(cr, uid, [ref('file_test2')])
77      self.unlink(cr, uid, [ref('attach_3rd')])
78 -
79     I delete the tests folder
80 -
81     !python {model: document.directory}: |
82       self.unlink(cr, uid, [ref('dir_tests')])