From: Mauro Scomparin Date: Tue, 10 Jul 2018 16:47:03 +0000 (+0200) Subject: added test and fixed #8 X-Git-Url: https://git.scompo.it/?a=commitdiff_plain;h=654e177438aa3469f144320e7f82be7cd470b3f1;p=money.git added test and fixed #8 --- diff --git a/money/money.py b/money/money.py index beb4e1d..0b947cb 100755 --- a/money/money.py +++ b/money/money.py @@ -175,6 +175,8 @@ def ordina(dati): def default_configuration(): return {DATA_FILE_NAME: 'movimenti.dat', LAST_MOVEMENT_NUMBER: 5} +def last_movement_number_message(n): + return 'ultimi {} movimenti:'.format(n) def riassunto(file_dati, conf): dati = carica_file(file_dati) @@ -192,7 +194,7 @@ def riassunto(file_dati, conf): print('valore attuale:', str(val_attuale)) print('guadagni complessivi:', str(guadagni_tot)) print('spese complessive:', str(spese_tot)) - print('ultimi 5 movimenti:') + print(last_movement_number_message(conf[LAST_MOVEMENT_NUMBER])) for i in range(conf[LAST_MOVEMENT_NUMBER]): if i < len(dati_ordinati): print(dati_ordinati[i]) diff --git a/money/tests/test_money.py b/money/tests/test_money.py index 059149f..ffb616a 100644 --- a/money/tests/test_money.py +++ b/money/tests/test_money.py @@ -10,6 +10,9 @@ class MoneyTest(unittest.TestCase): def test_passa_sempre(self): self.assertTrue(True, msg='se fallisce son problemi') + def test_riassunto_last_movement_number(self): + self.assertEqual(money.last_movement_number_message(10), "ultimi 10 movimenti:") + def test_config_file_name(self): self.assertEqual(money.CONFIG_FILE_NAME, 'money.conf')