fixed broken tests
authorMauro Scomparin <scompo@gmail.com>
Tue, 10 Jul 2018 19:48:51 +0000 (21:48 +0200)
committerMauro Scomparin <scompo@gmail.com>
Tue, 10 Jul 2018 19:48:51 +0000 (21:48 +0200)
money/tests/test_money.py

index 063de4db69d45cca90d8d85c729d9053dd90dd29..a49bdf7655af1cf6712fbdc7fae26c5fc6999bcf 100644 (file)
@@ -7,11 +7,12 @@ from money import money
 
 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')
@@ -23,7 +24,7 @@ class MoneyTest(unittest.TestCase):
     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)
 
@@ -33,7 +34,8 @@ class MoneyTest(unittest.TestCase):
 
     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')
@@ -42,26 +44,10 @@ class MoneyTest(unittest.TestCase):
 
     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)
@@ -70,6 +56,14 @@ class MoneyTest(unittest.TestCase):
         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()