Use high level API of res.user.warning in tests

This commit is contained in:
Nicolas Évrard
2024-11-29 18:18:52 +01:00
parent fb200e610d
commit 68fb5e1fa7
+18 -20
View File
@@ -17,6 +17,13 @@ class ResTestCase(ModuleTestCase):
'Test res module'
module = 'res'
@with_transaction()
def tearDown(self):
pool = Pool()
Warning_ = pool.get('res.user.warning')
Warning_.delete(Warning_.search([]))
Transaction().commit()
@unittest.skipUnless(PIL, "Avatars are not generated without PIL")
@with_transaction()
def test_user_avatar(self):
@@ -44,14 +51,12 @@ class ResTestCase(ModuleTestCase):
pool = Pool()
Warning_ = pool.get('res.user.warning')
user_id = Transaction().user
Warning_.create([{
'user': user_id,
'name': 'test',
}])
with Transaction().new_transaction():
Warning_.skip('test')
self.assertFalse(Warning_.check('test'))
self.assertFalse(Warning_.check('test'))
self.assertFalse(Warning_.search([]))
with Transaction().new_transaction():
self.assertTrue(Warning_.check('test'))
@with_transaction()
def test_user_warning_always_ignored(self):
@@ -59,15 +64,12 @@ class ResTestCase(ModuleTestCase):
pool = Pool()
Warning_ = pool.get('res.user.warning')
user_id = Transaction().user
Warning_.create([{
'user': user_id,
'name': 'test',
'always': True,
}])
with Transaction().new_transaction():
Warning_.skip('test', always=True)
self.assertFalse(Warning_.check('test'))
self.assertFalse(Warning_.check('test'))
self.assertTrue(Warning_.search([]))
with Transaction().new_transaction():
self.assertFalse(Warning_.check('test'))
@with_transaction()
def test_user_warning_reentrant(self):
@@ -75,11 +77,7 @@ class ResTestCase(ModuleTestCase):
pool = Pool()
Warning_ = pool.get('res.user.warning')
user_id = Transaction().user
Warning_.create([{
'user': user_id,
'name': 'test',
}])
Warning_.skip('test')
self.assertFalse(Warning_.check('test'))
self.assertFalse(Warning_.check('test'))