HOUR_FIELD_NAME = 'hour'
DESCRIPTION_FIELD_NAME = 'description'
+def create_input_message(field_name, field_format, field_default_value):
+ return field_name + " (" + field_format + ") [" + field_default_value + "]: "
+
+TYPE_MESSAGE = create_input_message(TYPE_FIELD_NAME, '+/-', '-')
+DATE_MESSAGE = create_input_message(DATE_FIELD_NAME, 'DD/MM/YYYY', 'today')
+HOUR_MESSAGE = create_input_message(HOUR_FIELD_NAME, 'HH:MM', 'now')
+VALUE_MESSAGE = create_input_message(VALUE_FIELD_NAME, '(#####.##)', '')
+DESCRIPTION_MESSAGE = create_input_message(DESCRIPTION_FIELD_NAME, '', '')
def write_movement(path, m):
with open(path, 'a') as f:
def read_type():
t = 'n'
while not (t == '' or t == '+' or t == '-'):
- t = input('type (+/-) [-]: ')
+ t = input(TYPE_MESSAGE)
if t == '':
t = '-'
elif t == '+':
def read_value():
v = ''
while v == '':
- v = input('value (#####.##) []: ')
+ v = input(VALUE_MESSAGE)
return v
def read_date():
- d = input('date (DD/MM/YYYY) [today]: ')
+ d = input(DATE_MESSAGE)
if d == '':
d = strftime("%d/%m/%Y", localtime())
return d
def read_hour():
- h = input('hour (HH:MM) [now]: ')
+ h = input(HOUR_MESSAGE)
if h == '':
h = strftime('%H:%M', localtime())
return h
def read_description():
- d = input('description () []: ')
+ d = input(DESCRIPTION_MESSAGE)
return d
def test_the_whole_univers(self):
self.assertTrue(True, msg='if this fails something is very wrong')
+ def test_create_input_message(self):
+ self.assertEqual(money.create_input_message(
+ 'f', '##', '0'), 'f (##) [0]: ')
+
def test_riassunto_last_movement_number(self):
self.assertEqual(money.last_movement_number_message(
10), "latest 10 movements:")