def test_finish_balancing_with_errors(self): """Verify things don't change when there are errors""" with FileTester.temp_input(testdata) as tempfilename: recon = Reconciler(LedgerFile(tempfilename, 'cash')) recon.finish_balancing() payees = { thing.payee for thing in recon.open_transactions } self.assertEqual( ({'two', 'two pt five', 'three', 'four'}), payees ) payees = { thing.payee for k, thing in recon.current_listing.iteritems() } # future items included only if pending ('three') self.assertEqual( ({'two', 'two pt five', 'three'}), payees ) recon.ending_balance = -1234.56 recon.finish_balancing() self.assertEqual(-1234.56, recon.ending_balance) payees = { thing.payee for thing in recon.open_transactions } self.assertEqual( ({'two', 'two pt five', 'three', 'four'}), payees ) payees = { thing.payee for k, thing in recon.current_listing.iteritems() } # future items included only if pending ('three') self.assertEqual( ({'two', 'two pt five', 'three'}), payees )
def test_finish_balancing_errors(self): with FileTester.temp_input(testdata) as tempfilename: recon = Reconciler(LedgerFile(tempfilename, 'cash')) self.reset_redirect() recon.finish_balancing() self.assertEqual( '*** Ending balance must be set in order to finish', self.redirect.getvalue().rstrip() ) self.reset_redirect() recon.ending_balance = -1234.56 recon.finish_balancing() self.assertEqual( '"To zero" must be zero in order to finish', self.redirect.getvalue().rstrip() ) # confirms it didn't revert to None as on success self.assertEqual(-1234.56, recon.ending_balance)