def test_list(self): with FileTester.temp_input(testdata) as tempfilename: recon = Reconciler(LedgerFile(tempfilename, 'cash')) recon.do_list('') 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 ) self.verify_equal_floats(-15, recon.total_cleared) self.verify_equal_floats(-32.12, recon.total_pending)
def test_mark_and_unmark_errors(self): with FileTester.temp_input(testdata) as tempfilename: recon = Reconciler(LedgerFile(tempfilename, 'cash')) self.reset_redirect() # none of these should result in a file write; we'll get out of # the context manager as an additional confirmation of this for command in [recon.do_mark, recon.do_unmark]: command('') self.assertEqual( '*** Transaction number(s) required', self.redirect.getvalue().rstrip() ) self.reset_redirect() command('ahchew') self.assertEqual( 'Transaction not found: ahchew', self.redirect.getvalue().rstrip() ) self.reset_redirect() recon.do_list('') self.reset_redirect() recon.do_mark('2') self.assertEqual( 'Already marked pending: 2', self.redirect.getvalue().rstrip() ) self.reset_redirect() recon.do_unmark('1') self.assertEqual( "Not marked; can't unmark: 1", self.redirect.getvalue().rstrip() )
def test_list_all(self): with FileTester.temp_input(testdata) as tempfilename: recon = Reconciler(LedgerFile(tempfilename, 'cash')) recon.do_list('') 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.do_list('aLL') payees = { thing.payee for k, thing in recon.current_listing.iteritems() } self.assertEqual( ({'two', 'two pt five', 'three', 'four'}), payees )
def test_list_and_modify(self): with FileTester.temp_input(testdata) as tempfilename: recon = Reconciler(LedgerFile(tempfilename, 'cash')) self.verify_equal_floats(-15, recon.total_cleared) self.verify_equal_floats(-32.12, recon.total_pending) recon.do_list('') payees = { thing.payee for k, thing in recon.current_listing.iteritems() } self.assertEqual( ({'two', 'two pt five', 'three'}), payees ) recon.do_unmark('3') # 3 was a pending future transaction, so: # pending total is adjusted and one less current listing # (also, the mark should have triggered a new listing...) payees = { thing.payee for k, thing in recon.current_listing.iteritems() } self.assertEqual(({'two', 'two pt five'}), payees) self.verify_equal_floats(-15, recon.total_cleared) self.verify_equal_floats(-2.12, recon.total_pending) # open transactions shouldn't change payees = { thing.payee for thing in recon.open_transactions } self.assertEqual( ({'two', 'two pt five', 'three', 'four'}), payees )