~openerp-dev/openobject-server/trunk-gunicorn-signaling-vmt

« back to all changes in this revision

Viewing changes to openerp/addons/base/test/test_ir_values.yml

  • Committer: Vo Minh Thu
  • Date: 2012-03-07 11:10:30 UTC
  • mfrom: (4001.1.83 server)
  • Revision ID: vmt@openerp.com-20120307111030-8hzhzm0zoo34nuj7
[MERGE] merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
-
2
 
    Create some default value for some (non-existing) model, for all users.
3
 
-
4
 
    !python {model: ir.values }: |
5
 
        # use the old API
6
 
        self.set(cr, uid, 'default', False, 'my_test_field',['unexisting_model'], 'global value')
7
 
        # use the new API
8
 
        self.set_default(cr, uid, 'other_unexisting_model', 'my_other_test_field', 'conditional value', condition='foo=bar')
9
 
-
10
 
    Retrieve them.
11
 
-
12
 
    !python {model: ir.values }: |
13
 
        # d is a list of triplets (id, name, value)
14
 
        # Old API
15
 
        d = self.get(cr, uid, 'default', False, ['unexisting_model'])
16
 
        assert len(d) == 1, "Only one single value should be retrieved for this model"
17
 
        assert d[0][1] == 'my_test_field', "Can't retrieve the created default value. (1)"
18
 
        assert d[0][2] == 'global value', "Can't retrieve the created default value. (2)"
19
 
 
20
 
        # New API, Conditional version
21
 
        d = self.get_defaults(cr, uid, 'other_unexisting_model')
22
 
        assert len(d) == 0, "No value should be retrieved, the condition is not met"
23
 
        d = self.get_defaults(cr, uid, 'other_unexisting_model', condition="foo=eggs")
24
 
        assert len(d) == 0, 'Condition is not met either, no defaults should be returned'
25
 
        d = self.get_defaults(cr, uid, 'other_unexisting_model', condition="foo=bar")
26
 
        assert len(d) == 1, "Only one single value should be retrieved"
27
 
        assert d[0][1] == 'my_other_test_field', "Can't retrieve the created default value. (5)"
28
 
        assert d[0][2] == 'conditional value', "Can't retrieve the created default value. (6)"
29
 
-
30
 
    Do it again but for a specific user.
31
 
-
32
 
    !python {model: ir.values }: |
33
 
        self.set(cr, uid, 'default', False, 'my_test_field',['unexisting_model'], 'specific value', preserve_user=True)
34
 
-
35
 
    Retrieve it and check it is the one for the current user.
36
 
-
37
 
    !python {model: ir.values }: |
38
 
        d = self.get(cr, uid, 'default', False, ['unexisting_model'])
39
 
        assert len(d) == 1, "Only one default must be returned per field"
40
 
        assert d[0][1] == 'my_test_field', "Can't retrieve the created default value."
41
 
        assert d[0][2] == 'specific value', "Can't retrieve the created default value."
42
 
-
43
 
    Create some action bindings for a non-existing model
44
 
-
45
 
    !python {model: ir.values }: |
46
 
        self.set(cr, uid, 'action', 'tree_but_open', 'OnDblClick Action', ['unexisting_model'], 'ir.actions.act_window,10', isobject=True)
47
 
        self.set(cr, uid, 'action', 'tree_but_open', 'OnDblClick Action 2', ['unexisting_model'], 'ir.actions.act_window,11', isobject=True)
48
 
        self.set(cr, uid, 'action', 'client_action_multi', 'Side Wizard', ['unexisting_model'], 'ir.actions.act_window,12', isobject=True)
49
 
        self.set(cr, uid, 'action', 'client_print_multi', 'Nice Report', ['unexisting_model'], 'ir.actions.report.xml,2', isobject=True)
50
 
        self.set(cr, uid, 'action', 'client_action_relate', 'Related Stuff', ['unexisting_model'], 'ir.actions.act_window,14', isobject=True)
51
 
-
52
 
    Replace one action binding to set a new name
53
 
-
54
 
    !python {model: ir.values }: |
55
 
        self.set(cr, uid, 'action', 'tree_but_open', 'OnDblClick Action New', ['unexisting_model'], 'ir.actions.act_window,10', isobject=True)
56
 
-
57
 
    Retrieve the action bindings and check they're correct
58
 
-
59
 
    !python {model: ir.values }: |
60
 
        actions = self.get(cr, uid, 'action', 'tree_but_open', ['unexisting_model'])
61
 
        assert len(actions) == 2, "Mismatching number of bound actions"
62
 
        #first action
63
 
        assert len(actions[0]) == 3, "Malformed action definition"
64
 
        assert actions[0][1] == 'OnDblClick Action 2', 'Bound action does not match definition'
65
 
        assert isinstance(actions[0][2], dict) and actions[0][2]['id'] == 11, 'Bound action does not match definition'
66
 
        #second action - this ones comes last because it was re-created with a different name
67
 
        assert len(actions[1]) == 3, "Malformed action definition"
68
 
        assert actions[1][1] == 'OnDblClick Action New', 'Re-Registering an action should replace it'
69
 
        assert isinstance(actions[1][2], dict) and actions[1][2]['id'] == 10, 'Bound action does not match definition'
70
 
 
71
 
        actions = self.get(cr, uid, 'action', 'client_action_multi', ['unexisting_model'])
72
 
        assert len(actions) == 1, "Mismatching number of bound actions"
73
 
        assert len(actions[0]) == 3, "Malformed action definition"
74
 
        assert actions[0][1] == 'Side Wizard', 'Bound action does not match definition'
75
 
        assert isinstance(actions[0][2], dict) and actions[0][2]['id'] == 12, 'Bound action does not match definition'
76
 
 
77
 
        actions = self.get(cr, uid, 'action', 'client_print_multi', ['unexisting_model'])
78
 
        assert len(actions) == 1, "Mismatching number of bound actions"
79
 
        assert len(actions[0]) == 3, "Malformed action definition"
80
 
        assert actions[0][1] == 'Nice Report', 'Bound action does not match definition'
81
 
        assert isinstance(actions[0][2], dict) and actions[0][2]['id'] == 2, 'Bound action does not match definition'
82
 
 
83
 
        actions = self.get(cr, uid, 'action', 'client_action_relate', ['unexisting_model'])
84
 
        assert len(actions) == 1, "Mismatching number of bound actions"
85
 
        assert len(actions[0]) == 3, "Malformed action definition"
86
 
        assert actions[0][1] == 'Related Stuff', 'Bound action does not match definition'
87
 
        assert isinstance(actions[0][2], dict) and actions[0][2]['id'] == 14, 'Bound action does not match definition'