def test_get_lines_indent_change(self): # status doesn't change, but indent does due to standard # uncleared lines = ( '2016/10/24 glob', ' ; might as well test comment handling, too', ' e: blurg', ' a: smurg $-25', ) thing = LedgerThing(list(lines), 'smurg') expected = ( '2016/10/24 glob', ' ; might as well test comment handling, too', ' e: blurg', ' a: smurg $-25', ) self.assertEqual(expected, tuple(thing.get_lines())) # pending lines = ('2016/10/24 glob', ' !e: blurg', ' a: smurg $-25') thing = LedgerThing(list(lines), 'blurg') self.assertEqual( ('2016/10/24 glob', ' ! e: blurg', ' a: smurg $-25'), tuple(thing.get_lines()) ) # cleared lines = ('2016/10/24 glob', ' *e: blurg', ' a: smurg $-25') thing = LedgerThing(list(lines), 'blurg') self.assertEqual( ('2016/10/24 glob', ' * e: blurg', ' a: smurg $-25'), tuple(thing.get_lines()) )
def test_get_lines_dates(self): # same date lines = ('2016/10/24 blah', ' e: blurg') thing = LedgerThing(list(lines)) self.assertEqual(lines, tuple(thing.get_lines())) # change date thing.thing_date = date(1998, 3, 8) self.assertEqual( ['1998/03/08 blah', ' e: blurg'], thing.get_lines() )
def test_get_lines_reconciled_status_no_change(self): # uncleared lines = ('2016/10/24 glob', ' e: blurg', ' a: smurg $-25') thing = LedgerThing(list(lines), 'smurg') self.assertEqual(lines, tuple(thing.get_lines())) # pending lines = ('2016/10/24 glob', ' ! e: blurg', ' a: smurg $-25') thing = LedgerThing(list(lines), 'blurg') self.assertEqual(lines, tuple(thing.get_lines())) # cleared lines = ('2016/10/24 glob', ' * e: blurg', ' a: smurg $-25') thing = LedgerThing(list(lines), 'blurg') self.assertEqual(lines, tuple(thing.get_lines()))
def test_get_lines_status_changes(self): # uncleared -> pending lines = ('2016/10/24 abc', ' e: xyz', ' a: smurg $-25') thing = LedgerThing(list(lines), 'smurg') thing.rec_status = LedgerThing.REC_PENDING self.assertEqual( ('2016/10/24 abc', ' e: xyz', ' ! a: smurg $-25'), tuple(thing.get_lines()) ) # pending -> cleared thing.rec_status = LedgerThing.REC_CLEARED self.assertEqual( ('2016/10/24 abc', ' e: xyz', ' * a: smurg $-25'), tuple(thing.get_lines()) ) # cleared -> uncleared thing.rec_status = LedgerThing.REC_UNCLEARED self.assertEqual( ('2016/10/24 abc', ' e: xyz', ' a: smurg $-25'), tuple(thing.get_lines()) )
def test_get_lines_status_change_multiple_lines(self): lines = ( '2016/10/24 glob', ' ; might as well test comment handling, too', ' e: blurg $50', ' a: smurg', ' a: smurg $-25', ) thing = LedgerThing(list(lines), 'smurg') thing.rec_status = LedgerThing.REC_PENDING expected = ( '2016/10/24 glob', ' ; might as well test comment handling, too', ' e: blurg $50', ' ! a: smurg', ' ! a: smurg $-25', ) self.assertEqual( expected, tuple(thing.get_lines()) ) self.assertEqual('', self.redirect.getvalue().rstrip())
def test_get_lines(self): """lines can be entered and retrieved as is""" lines = ('abc\n', 'xyz\n') thing = LedgerThing(list(lines)) self.assertEqual(lines, tuple(thing.get_lines()))