HOUR_FIELD_NAME = 'hour'
DESCRIPTION_FIELD_NAME = 'description'
+
def write_movement(path, m):
with open(path, 'a') as f:
f.write(m[TYPE_FIELD_NAME] + m[VALUE_FIELD_NAME])
def default_configuration():
return {DATA_FILE_NAME: 'movements.dat', LAST_MOVEMENT_NUMBER: 5}
+
def last_movement_number_message(n):
return 'latest {} movements:'.format(n)
+
+def actual_value_message(value):
+ return 'actual value: {}'.format(str(value))
+
+
def write_latest_movements(data_file, conf):
movements = load_file(data_file)
ordered_movements = sort_movements(movements)
total_incomes = total_incomes + movement_value
else:
total_expenses = total_expenses + movement_value
- print('actual value:', str(actual_value))
+ print(actual_value_message(actual_value))
print('total incomes:', str(total_incomes))
print('total expenses:', str(total_expenses))
print(last_movement_number_message(conf[LAST_MOVEMENT_NUMBER]))
import unittest
import tempfile
import json
+from decimal import *
from os.path import expanduser
from money import money
self.assertEqual(money.last_movement_number_message(
10), "latest 10 movements:")
+ def test_actual_value_message(self):
+ self.assertEqual(money.actual_value_message(
+ Decimal(10.00)), "actual value: 10")
+
def test_config_file_name(self):
self.assertEqual(money.CONFIG_FILE_NAME, 'money.conf')