Commit a9fe36b0 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_cloud: (Test) Ensure returned object is consistent

   This prevents produce inconsistent objects whenever system evolve.
parent e94a14f4
...@@ -27,9 +27,7 @@ class TestSlapOSManualAccountingScenarioMixin(TestSlapOSVirtualMasterScenarioMix ...@@ -27,9 +27,7 @@ class TestSlapOSManualAccountingScenarioMixin(TestSlapOSVirtualMasterScenarioMix
self.tic() self.tic()
self.login(sale_person.getUserId()) self.login(sale_person.getUserId())
self.addAccountingManagerAssignment(accountant_person)
assignment = self.addAccountingManagerAssignment(accountant_person)
self.assertEqual(assignment.checkConsistency(), [])
self.tic() self.tic()
self.logout() self.logout()
......
...@@ -78,6 +78,15 @@ def withAbort(func): ...@@ -78,6 +78,15 @@ def withAbort(func):
self.abort() self.abort()
return wrapped return wrapped
def ensureConsistency(func):
@functools.wraps(func)
def wrapped(self, *args, **kwargs):
document = func(self, *args, **kwargs)
consistency_list = document.checkConsistency()
assert not len(consistency_list), consistency_list
return document
return wrapped
class TemporaryAlarmScript(object): class TemporaryAlarmScript(object):
""" """
...@@ -163,6 +172,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -163,6 +172,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
# Reset values set on script_ComputeNode_requestSoftwareReleaseChange # Reset values set on script_ComputeNode_requestSoftwareReleaseChange
self.portal.REQUEST.set(key, None) self.portal.REQUEST.set(key, None)
@ensureConsistency
def _addAssignment(self, person, function, project=None, **kw): def _addAssignment(self, person, function, project=None, **kw):
assignment = person.newContent( assignment = person.newContent(
portal_type='Assignment', portal_type='Assignment',
...@@ -227,6 +237,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin): ...@@ -227,6 +237,7 @@ class SlapOSTestCaseMixin(testSlapOSMixin):
return subscription_request.getAggregate()""" return subscription_request.getAggregate()"""
@ensureConsistency
def _addERP5Login(self, document, **kw): def _addERP5Login(self, document, **kw):
if document.getPortalType() != "Person": if document.getPortalType() != "Person":
raise ValueError("Only Person supports add ERP5 Login") raise ValueError("Only Person supports add ERP5 Login")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment