Commit 7b14f209 authored by Łukasz Nowak's avatar Łukasz Nowak

Improve coverage scope.

Check behaviour of Delivery_updateCausalityState in case of been called on
documents with various states.
parent 58496859
...@@ -25,6 +25,7 @@ def withAbort(func): ...@@ -25,6 +25,7 @@ def withAbort(func):
class Simulator: class Simulator:
def __init__(self, outfile, method, to_return=None): def __init__(self, outfile, method, to_return=None):
self.outfile = outfile self.outfile = outfile
open(self.outfile, 'w').write(repr([]))
self.method = method self.method = method
self.to_return = to_return self.to_return = to_return
...@@ -92,11 +93,11 @@ class TestAlarm(testSlapOSMixin): ...@@ -92,11 +93,11 @@ class TestAlarm(testSlapOSMixin):
self._test('solved', 'Not visited by Delivery_updateCausalityState') self._test('solved', 'Not visited by Delivery_updateCausalityState')
@withAbort @withAbort
def test_Delivery_updateCausalityState(self): def _test_Delivery_updateCausalityState(self, state, empty=False):
delivery = self.portal.sale_packing_list_module.newContent( delivery = self.portal.sale_packing_list_module.newContent(
title='Not visited by Delivery_updateCausalityState', title='Not visited by Delivery_updateCausalityState',
portal_type='Sale Packing List') portal_type='Sale Packing List')
self.portal.portal_workflow._jumpToStateFor(delivery, 'calculating') self.portal.portal_workflow._jumpToStateFor(delivery, state)
updateCausalityState_simulator = tempfile.mkstemp()[1] updateCausalityState_simulator = tempfile.mkstemp()[1]
try: try:
...@@ -110,14 +111,29 @@ class TestAlarm(testSlapOSMixin): ...@@ -110,14 +111,29 @@ class TestAlarm(testSlapOSMixin):
value = eval(open(updateCausalityState_simulator).read()) value = eval(open(updateCausalityState_simulator).read())
self.assertEqual([{ if empty:
'recmethod': 'updateCausalityState', self.assertEqual([], value)
'recargs': (), else:
'reckwargs': {'solve_automatically': False}}], self.assertEqual([{
value 'recmethod': 'updateCausalityState',
) 'recargs': (),
'reckwargs': {'solve_automatically': False}}],
value
)
finally: finally:
Delivery.updateCausalityState = Delivery.original_updateCausalityState Delivery.updateCausalityState = Delivery.original_updateCausalityState
delattr(Delivery, 'original_updateCausalityState') delattr(Delivery, 'original_updateCausalityState')
if os.path.exists(updateCausalityState_simulator): if os.path.exists(updateCausalityState_simulator):
os.unlink(updateCausalityState_simulator) os.unlink(updateCausalityState_simulator)
def test_Delivery_updateCausalityState_calculating(self):
self._test_Delivery_updateCausalityState('calculating')
def test_Delivery_updateCausalityState_building(self):
self._test_Delivery_updateCausalityState('building')
def test_Delivery_updateCausalityState_solved(self):
self._test_Delivery_updateCausalityState('solved', True)
def test_Delivery_updateCausalityState_diverged(self):
self._test_Delivery_updateCausalityState('diverged', True)
40 41
\ No newline at end of file \ No newline at end of file
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