class MoneyTest(unittest.TestCase):
- def test_passa_sempre(self):
- self.assertTrue(True, msg='se fallisce son problemi')
+ def test_the_whole_univers(self):
+ self.assertTrue(True, msg='if this fails something is very wrong')
def test_riassunto_last_movement_number(self):
- self.assertEqual(money.last_movement_number_message(10), "latest 10 movements:")
+ self.assertEqual(money.last_movement_number_message(
+ 10), "latest 10 movements:")
def test_config_file_name(self):
self.assertEqual(money.CONFIG_FILE_NAME, 'money.conf')
def test_default_configuration(self):
conf = money.default_configuration()
self.assertTrue(money.DATA_FILE_NAME in conf)
- self.assertEqual(conf[money.DATA_FILE_NAME], 'movimenti.dat')
+ self.assertEqual(conf[money.DATA_FILE_NAME], 'movements.dat')
self.assertTrue(money.LAST_MOVEMENT_NUMBER in conf)
self.assertEqual(conf[money.LAST_MOVEMENT_NUMBER], 5)
def test_override_default_configuration(self):
def_conf = money.default_configuration()
- new_conf = {money.DATA_FILE_NAME: 'new-file.dat', money.LAST_MOVEMENT_NUMBER : 10}
+ new_conf = {money.DATA_FILE_NAME: 'new-file.dat',
+ money.LAST_MOVEMENT_NUMBER: 10}
res = money.override_default_configuration(def_conf, new_conf)
self.assertTrue(money.DATA_FILE_NAME in res)
self.assertEqual(res[money.DATA_FILE_NAME], 'new-file.dat')
def test_sort_movements(self):
date = [
- {
- 'data': '18/04/2017',
- 'ora': '00:01',
- 'prog': 1,
- },
- {
- 'data': '19/04/2017',
- 'ora': '00:01',
- 'prog': 2,
- },
- {
- 'data': '17/04/2017',
- 'ora': '',
- 'prog': 3,
- },
- {
- 'data': '',
- 'ora': '00:01',
- 'prog': 4,
- },
+ create_test_movement('18/04/2017', '00:01', 1),
+ create_test_movement('19/04/2017', '00:01', 2),
+ create_test_movement('17/04/2017', '', 3),
+ create_test_movement('', '00:01', 4),
]
res = money.sort_movements(date)
self.assertEqual(res[0]['prog'], 2)
self.assertEqual(res[3]['prog'], 4)
+def create_test_movement(date, hour, prog):
+ return {
+ money.DATE_FIELD_NAME: date,
+ money.HOUR_FIELD_NAME: hour,
+ 'prog': prog,
+ }
+
+
def main():
unittest.main()