def test_initial_non_transaction_date(self): """1st thing in file is a non-transaction, has default date""" tempfile = FileTester.create_temp_file('blah\nblah blah blah') ledgerfile = LedgerFile(tempfile) # non-transaction dates are only populated with sort ledgerfile.sort() remove(tempfile) self.assertEqual( LedgerFile.STARTING_DATE, ledgerfile.get_things()[0].thing_date )
def test_later_non_transaction_date(self): """later non-transaction things inherit preceding thing date""" testdata = '''2013/05/06 payee name expenses: misc liabilities: credit card $-1 2013/05/07 payee name expenses: misc liabilities: credit card $-2 ''' tempfile = FileTester.create_temp_file(testdata) ledgerfile = LedgerFile(tempfile) ledgerfile._add_thing_from_lines( ['; blah blah blah', '; and so on...'] ) # non-transaction dates are only populated with sort ledgerfile.sort() remove(tempfile) self.assertEqual( ledgerfile.get_things()[1].thing_date, ledgerfile.get_things()[2].thing_date )
def test_assigned_thing_numbers(self): """thing numbers added in sequence starting at one""" testdata = '''; blah ; blah blah blah 2013/05/06 payee name expenses: misc liabilities: credit card $-50 ''' tempfile = FileTester.create_temp_file(testdata) ledgerfile = LedgerFile(tempfile) remove(tempfile) thing = LedgerThing([ '2011/01/01 beezlebub', ' assets: soul', ' liabilities: credit card $666', ]) ledgerfile.add_thing(thing) expected = '012' actual = '' for thing in ledgerfile.get_things(): actual += str(thing.thing_number) self.assertEquals(actual, expected)