[IMP] use a better syntax for the test

This commit is contained in:
houssine
2020-11-27 15:57:23 +01:00
parent 66e528ca5b
commit bb6280471a
5 changed files with 5 additions and 45 deletions

View File

@@ -1,3 +1,2 @@
from . import models
from . import wizard

View File

@@ -1,4 +1,3 @@
from . import account_move
from . import company
from . import res_config

View File

@@ -1,3 +1 @@
# © 2016 Camptocamp SA (Matthieu Dietrich)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import test_permanent_lock

View File

@@ -47,19 +47,12 @@ class PermanentLock(common.TransactionCase):
})
# Call lock wizard on entry
raised_lock_error = False
try:
with self.assertRaises(UserError):
self.wizard = self.wizard_obj.create({
'company_id': self.company_id,
'lock_date': fields.Date.today()
})
self.wizard.confirm_date()
except UserError as ue:
if 'entries are still unposted' in ue.name:
raised_lock_error = True
self.assertTrue(raised_lock_error,
"Permanent lock done even with unposted entry.")
# Post entry and lock
self.move.post()
@@ -77,26 +70,16 @@ class PermanentLock(common.TransactionCase):
self.wizard.confirm_date()
# Try to lock the day before
raised_lock_error = False
try:
with self.assertRaises(UserError):
yesterday = fields.Date.today() + datetime.timedelta(days=-1)
self.wizard = self.wizard_obj.create({
'company_id': self.company_id,
'lock_date': yesterday
})
self.wizard.confirm_date()
except UserError as ue:
if 'permanent lock date in the past' in ue.name:
raised_lock_error = True
self.assertTrue(raised_lock_error,
"Permanent lock set the day before.")
# Test that the move cannot be created, written, or cancelled
raised_create_error = False
raised_write_error = False
raised_cancel_error = False
try:
with self.assertRaises(UserError):
self.move2 = self.account_move_obj.create({
'date': fields.Date.today(),
'journal_id': self.journal_id,
@@ -110,27 +93,9 @@ class PermanentLock(common.TransactionCase):
'name': 'Debit line',
})]
})
except UserError as ue:
if 'permanent lock date' in ue.name:
raised_create_error = True
self.assertTrue(raised_create_error,
"Journal Entry could be created after locking!")
try:
with self.assertRaises(UserError):
self.move.write({'name': 'TEST'})
except UserError as ue:
if 'permanent lock date' in ue.name:
raised_write_error = True
self.assertTrue(raised_write_error,
"Journal Entry could be modified after locking!")
try:
with self.assertRaises(UserError):
self.move.button_cancel()
except UserError as ue:
if 'permanent lock date' in ue.name:
raised_cancel_error = True
self.assertTrue(raised_cancel_error,
"Journal Entry could be cancelled after locking!")

View File

@@ -1,2 +1 @@
from . import permanent_lock_date_wizard