~vauxoo/addons-vauxoo/6.0-trunk

« back to all changes in this revision

Viewing changes to contract_log_term_condition/tests/test_contract.py

  • Committer: Jose Morales
  • Date: 2014-07-28 20:00:11 UTC
  • mfrom: (543.7.551 7.0-addons-vauxoo)
  • Revision ID: jose@vauxoo.com-20140728200011-csytovehrzwp24lr
[FORWARD PORT] 7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from openerp.tests.common import TransactionCase
 
2
from openerp.exceptions import AccessError
 
3
from openerp.osv.orm import except_orm
 
4
from openerp import SUPERUSER_ID
 
5
 
 
6
class TestAnalytic(TransactionCase):
 
7
 
 
8
    def setUp(self):
 
9
        super(TestAnalytic, self).setUp()
 
10
        self.analytic = self.registry('account.analytic.account')
 
11
        self.message = self.registry('mail.message')
 
12
        self.user = self.registry('res.users')
 
13
 
 
14
 
 
15
    def test_log_terms_conditions(self):
 
16
        '''
 
17
        Check if the log about terms and conditions field was created
 
18
        '''
 
19
        cr, uid = self.cr, self.uid
 
20
        user_brw = self.user.browse(cr, uid, uid)
 
21
        partner_brw = user_brw.partner_id
 
22
        analytic_id = self.analytic.create(cr, uid, {
 
23
            'name': 'Test Terms and Conditions Log',
 
24
            'code': 'TERMANDCONDITIONS',
 
25
            'description': 'Firs Condition',
 
26
            })
 
27
        message_ids = self.message.search(cr, uid,
 
28
                                 [('res_id', '=', analytic_id),
 
29
                                  ('model', '=', 'account.analytic.account'),
 
30
                                  ('body', 'ilike', '%'+'Firs Condition'+'%')])
 
31
 
 
32
        self.assertGreaterEqual(len(message_ids),
 
33
                                1,
 
34
                                "The log was not created")
 
35
        self.analytic.write(cr, uid, [analytic_id], {
 
36
            'description': 'Term Changed'
 
37
            })
 
38
 
 
39
        message_ids = self.message.search(cr, uid,
 
40
                                 [('res_id', '=', analytic_id),
 
41
                                  ('model', '=', 'account.analytic.account'),
 
42
                                  ('body', 'ilike', '%'+'Term Changed'+'%')])
 
43
 
 
44
        self.assertGreaterEqual(len(message_ids),
 
45
                                1,
 
46
                                "The log was not created")