|
@@ -29,6 +29,15 @@ class TestModel(unittest.TestCase):
|
29
|
29
|
model = Model(EmBackendJson('EditorialModel/test/me.json'), migration_handler=DjangoMigrationHandler('LodelTestInstance', debug=False, dryrun=True))
|
30
|
30
|
self.assertTrue(isinstance(model, Model))
|
31
|
31
|
|
|
32
|
+ def test_bad_init(self):
|
|
33
|
+ """ Test initialisation with bad arguments """
|
|
34
|
+ for bad in [ None, int, EmBackendDummy, DummyMigrationHandler, 'foobar' ]:
|
|
35
|
+ with self.assertRaises(TypeError, msg="Tried to instanciate a Model with a bad backend"):
|
|
36
|
+ Model(bad)
|
|
37
|
+ for bad in [ int, EmBackendDummy, DummyMigrationHandler, 'foobar' ]:
|
|
38
|
+ with self.assertRaises(TypeError, msg="Tried to instanciate a Model with a migration_handler"):
|
|
39
|
+ Model(EmBackendDummy(), bad)
|
|
40
|
+
|
32
|
41
|
def test_components(self):
|
33
|
42
|
""" Test components fetching """
|
34
|
43
|
uid_l = list()
|
|
@@ -196,12 +205,12 @@ class TestModel(unittest.TestCase):
|
196
|
205
|
def test_set_backend(self):
|
197
|
206
|
""" Test the set_backend method """
|
198
|
207
|
|
199
|
|
- for backend in [ None, EmBackendJson('EditorialModel/test/me.json'), EmBackendDummy() ]:
|
|
208
|
+ for backend in [ EmBackendJson('EditorialModel/test/me.json'), EmBackendDummy() ]:
|
200
|
209
|
self.me.set_backend(backend)
|
201
|
210
|
self.assertEqual(self.me.backend, backend)
|
202
|
211
|
|
203
|
|
- for bad_backend in ['wow', int, EmBackendJson ]:
|
204
|
|
- with self.assertRaises(AttributeError, msg="But bad argument (%s %s) was given"%(type(bad_backend),bad_backend)):
|
|
212
|
+ for bad_backend in [None, 'wow', int, EmBackendJson ]:
|
|
213
|
+ with self.assertRaises(TypeError, msg="But bad argument (%s %s) was given"%(type(bad_backend),bad_backend)):
|
205
|
214
|
self.me.set_backend(bad_backend)
|
206
|
215
|
##
|
207
|
216
|
# @todo Test selected fields application
|
|
@@ -287,11 +296,4 @@ class TestModel(unittest.TestCase):
|
287
|
296
|
for cls in [EmComponent, int, str]:
|
288
|
297
|
self.assertFalse(Model.name_from_emclass(cls))
|
289
|
298
|
|
290
|
|
- def test_load_save_invalid(self):
|
291
|
|
- """ Test the behavior of a Model when no backend given but load and save are called """
|
292
|
|
- bad_em = Model(None)
|
293
|
|
-
|
294
|
|
- self.assertFalse(bad_em.load())
|
295
|
|
- self.assertFalse(bad_em.save())
|
296
|
|
-
|
297
|
299
|
|