Browse Source

[IMP] use a model for test that is not influenced by the mail module

pull/1040/head
Holger Brunn 10 years ago
committed by Enric Tobella
parent
commit
1ba22f8d7f
No known key found for this signature in database GPG Key ID: 1A2546A1B7BA2451
  1. 27
      auditlog/tests/test_auditlog.py

27
auditlog/tests/test_auditlog.py

@ -24,33 +24,32 @@ from openerp.tests.common import TransactionCase
class TestAuditlog(TransactionCase): class TestAuditlog(TransactionCase):
def test_LogCreation(self): def test_LogCreation(self):
auditlog_log = self.env['auditlog.log'] auditlog_log = self.env['auditlog.log']
user_model_id = self.env.ref('base.model_res_users').id
groups_model_id = self.env.ref('base.model_res_groups').id
self.env['auditlog.rule'].create({ self.env['auditlog.rule'].create({
'name': 'testrule for users',
'model_id': user_model_id,
'name': 'testrule for groups',
'model_id': groups_model_id,
'log_create': True, 'log_create': True,
'log_write': True, 'log_write': True,
'log_unlink': True, 'log_unlink': True,
'state': 'subscribed', 'state': 'subscribed',
}) })
user = self.env['res.users'].create({
'login': 'testuser',
'name': 'testuser',
group = self.env['res.groups'].create({
'name': 'testgroup',
}) })
self.assertTrue(auditlog_log.search([ self.assertTrue(auditlog_log.search([
('model_id', '=', user_model_id),
('model_id', '=', groups_model_id),
('method', '=', 'create'), ('method', '=', 'create'),
('res_id', '=', user.id),
('res_id', '=', group.id),
])) ]))
user.write({'name': 'Test User'})
group.write({'name': 'Testgroup'})
self.assertTrue(auditlog_log.search([ self.assertTrue(auditlog_log.search([
('model_id', '=', user_model_id),
('model_id', '=', groups_model_id),
('method', '=', 'write'), ('method', '=', 'write'),
('res_id', '=', user.id),
('res_id', '=', group.id),
])) ]))
user.unlink()
group.unlink()
self.assertTrue(auditlog_log.search([ self.assertTrue(auditlog_log.search([
('model_id', '=', user_model_id),
('model_id', '=', groups_model_id),
('method', '=', 'unlink'), ('method', '=', 'unlink'),
('res_id', '=', user.id),
('res_id', '=', group.id),
])) ]))
Loading…
Cancel
Save