Browse Source

Updates on Model tests

Yann Weber 9 years ago
parent
commit
5bccb6bae2
1 changed files with 8 additions and 4 deletions
  1. 8
    4
      EditorialModel/test/test_model.py

+ 8
- 4
EditorialModel/test/test_model.py View File

@@ -97,15 +97,19 @@ class TestModel(unittest.TestCase):
97 97
                 self.me.create_component(bad_comp_name, testDatas)
98 98
 
99 99
         #Invalid rank
100
-        for invalid_rank in [-1, 10000, 'laaaaast', 'tsrif']:
100
+        for invalid_rank in [-1, 10000]:
101 101
             with self.assertRaises(ValueError, msg="A invalid rank (%s) was given"%invalid_rank):
102 102
                 foodat = testDatas.copy()
103 103
                 foodat['rank'] = invalid_rank
104
-                self.me.create_component('EmClass', testDatas)
104
+                self.me.create_component('EmClass', foodat)
105
+        with self.assertRaises(TypeError, msg="A non integer rank was given"):
106
+            foodat = testDatas.copy()
107
+            foodat['rank'] = 'hello world'
108
+            self.me.create_component('EmClass', foodat)
105 109
 
106 110
         #Invalid datas
107 111
         for invalid_datas in [ dict(), [1,2,3,4], ('hello', 'world') ]:
108
-            with self.assertRaises(ValueError, msg="Invalid datas was given in parameters"):
112
+            with self.assertRaises(TypeError, msg="Invalid datas was given in parameters"):
109 113
                 self.me.create_component('EmClass', invalid_datas)
110 114
 
111 115
     def test_create_components(self):
@@ -248,7 +252,7 @@ class TestModel(unittest.TestCase):
248 252
     def test_hash(self):
249 253
         """ Test that __hash__ and __eq__ work properly on models """
250 254
         me1 = Model(EmBackendJson('EditorialModel/test/me.json'))
251
-        me2 = Model(EmBackendJson('EditorialModel/test/me.json'), migration_handler=DjangoMigrationHandler('LodelTestInstance', debug=True))
255
+        me2 = Model(EmBackendJson('EditorialModel/test/me.json'), migration_handler=DjangoMigrationHandler('LodelTestInstance', debug=False, dryrun=True))
252 256
 
253 257
         self.assertEqual(hash(me1), hash(me2), "When instanciate from the same backend & file but with another migration handler the hashes differs")
254 258
         self.assertTrue(me1.__eq__(me2))

Loading…
Cancel
Save