Commit 6a70229e authored by Jérome Perrin's avatar Jérome Perrin

bank_reconciliation: assert full constraint message

Instead of only checking that an error is reported, check the expected
error message, so that we are sure that this test really covers what
it's supposed to cover.
parent d4eda7ea
......@@ -368,30 +368,41 @@ class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase):
# reconciled balance must match
bank_reconciliation.setQuantityRangeMax(10)
self.assertEqual(1, len(bank_reconciliation.checkConsistency()))
self.assertEqual(
[str(m.getTranslatedMessage()) for m in bank_reconciliation.checkConsistency()],
["Bank statement balance does not match reconciled balance"])
bank_reconciliation.setQuantityRangeMax(100)
self.assertEqual(0, len(bank_reconciliation.checkConsistency()))
self.assertEqual(
[str(m.getTranslatedMessage()) for m in bank_reconciliation.checkConsistency()], [])
self.assertEqual(0, len(previous_bank_reconciliation.checkConsistency()))
self.assertEqual(
[str(m.getTranslatedMessage()) for m in previous_bank_reconciliation.checkConsistency()], [])
previous_bank_reconciliation.setQuantityRangeMax(10)
self.assertEqual(1, len(previous_bank_reconciliation.checkConsistency()))
self.assertEqual(
[str(m.getTranslatedMessage()) for m in previous_bank_reconciliation.checkConsistency()],
['Bank statement balance does not match reconciled balance'])
previous_bank_reconciliation.setQuantityRangeMax(100)
# Previous reconciled balance must match as well
bank_reconciliation.setStartDate(DateTime(2014, 1, 31))
bank_reconciliation.setQuantityRangeMin(10)
self.assertEqual(1, len(bank_reconciliation.checkConsistency()))
self.assertEqual(
[str(m.getTranslatedMessage()) for m in bank_reconciliation.checkConsistency()],
['Previous bank statement balance does not match reconciled balance at previous bank statement date'])
# These constraints are only verified when we go from open to close state.
# (that is why the bank reconciliation have been openned for the
# assertions above)
with self.assertRaises(ValidationFailed):
with self.assertRaisesRegexp(
ValidationFailed,
"Previous bank statement balance does not match reconciled balance at previous bank statement date"):
self.portal.portal_workflow.doActionFor(
bank_reconciliation,
'close_action')
bank_reconciliation.setQuantityRangeMin(100)
self.assertEqual(0, len(bank_reconciliation.checkConsistency()))
self.assertEqual(
[str(m.getTranslatedMessage()) for m in bank_reconciliation.checkConsistency()], [])
self.portal.portal_workflow.doActionFor(
bank_reconciliation,
'close_action')
......
......@@ -6,6 +6,12 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testBankReconciliation</string> </value>
......@@ -53,13 +59,28 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -72,7 +93,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -81,7 +102,7 @@
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
......
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