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
                 self.me.create_component(bad_comp_name, testDatas)
97
                 self.me.create_component(bad_comp_name, testDatas)
98
 
98
 
99
         #Invalid rank
99
         #Invalid rank
100
-        for invalid_rank in [-1, 10000, 'laaaaast', 'tsrif']:
100
+        for invalid_rank in [-1, 10000]:
101
             with self.assertRaises(ValueError, msg="A invalid rank (%s) was given"%invalid_rank):
101
             with self.assertRaises(ValueError, msg="A invalid rank (%s) was given"%invalid_rank):
102
                 foodat = testDatas.copy()
102
                 foodat = testDatas.copy()
103
                 foodat['rank'] = invalid_rank
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
         #Invalid datas
110
         #Invalid datas
107
         for invalid_datas in [ dict(), [1,2,3,4], ('hello', 'world') ]:
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
                 self.me.create_component('EmClass', invalid_datas)
113
                 self.me.create_component('EmClass', invalid_datas)
110
 
114
 
111
     def test_create_components(self):
115
     def test_create_components(self):
248
     def test_hash(self):
252
     def test_hash(self):
249
         """ Test that __hash__ and __eq__ work properly on models """
253
         """ Test that __hash__ and __eq__ work properly on models """
250
         me1 = Model(EmBackendJson('EditorialModel/test/me.json'))
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
         self.assertEqual(hash(me1), hash(me2), "When instanciate from the same backend & file but with another migration handler the hashes differs")
257
         self.assertEqual(hash(me1), hash(me2), "When instanciate from the same backend & file but with another migration handler the hashes differs")
254
         self.assertTrue(me1.__eq__(me2))
258
         self.assertTrue(me1.__eq__(me2))

Loading…
Cancel
Save