Browse Source

[IMP] Module 'auditlog' - Added a second test using cached data generated during the first test

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

11
auditlog/tests/test_auditlog.py

@ -23,6 +23,7 @@ from openerp.tests.common import TransactionCase
class TestAuditlog(TransactionCase): class TestAuditlog(TransactionCase):
def test_LogCreation(self): def test_LogCreation(self):
"""First test, caching some data."""
auditlog_log = self.env['auditlog.log'] auditlog_log = self.env['auditlog.log']
groups_model_id = self.env.ref('base.model_res_groups').id groups_model_id = self.env.ref('base.model_res_groups').id
self.env['auditlog.rule'].create({ self.env['auditlog.rule'].create({
@ -34,14 +35,14 @@ class TestAuditlog(TransactionCase):
'state': 'subscribed', 'state': 'subscribed',
}) })
group = self.env['res.groups'].create({ group = self.env['res.groups'].create({
'name': 'testgroup',
'name': 'testgroup1',
}) })
self.assertTrue(auditlog_log.search([ self.assertTrue(auditlog_log.search([
('model_id', '=', groups_model_id), ('model_id', '=', groups_model_id),
('method', '=', 'create'), ('method', '=', 'create'),
('res_id', '=', group.id), ('res_id', '=', group.id),
])) ]))
group.write({'name': 'Testgroup'})
group.write({'name': 'Testgroup1'})
self.assertTrue(auditlog_log.search([ self.assertTrue(auditlog_log.search([
('model_id', '=', groups_model_id), ('model_id', '=', groups_model_id),
('method', '=', 'write'), ('method', '=', 'write'),
@ -53,3 +54,9 @@ class TestAuditlog(TransactionCase):
('method', '=', 'unlink'), ('method', '=', 'unlink'),
('res_id', '=', group.id), ('res_id', '=', group.id),
])) ]))
def test_LogCreation2(self):
"""Second test, using cached data of the first one."""
self.env['res.groups'].create({
'name': 'testgroup2',
})
Loading…
Cancel
Save