From eaf0520d3bf08241f3d719792f829c5c6e7614c2 Mon Sep 17 00:00:00 2001 From: Roland Haroutiounian Date: Fri, 18 Sep 2015 11:31:17 +0200 Subject: [PATCH] [#49] Changed the migration handler used in the tests for Model --- EditorialModel/test/test_model.py | 36 +++++++++++++++---------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/EditorialModel/test/test_model.py b/EditorialModel/test/test_model.py index 4e6c6ea..ed37369 100644 --- a/EditorialModel/test/test_model.py +++ b/EditorialModel/test/test_model.py @@ -7,19 +7,20 @@ from EditorialModel.fieldgroups import EmFieldGroup from EditorialModel.fields import EmField from EditorialModel.backend.json_backend import EmBackendJson -from EditorialModel.migrationhandler.dummy import DummyMigrationHandler +#from EditorialModel.migrationhandler.dummy import DummyMigrationHandler +from EditorialModel.migrationhandler.django import DjangoMigrationHandler class TestModel(unittest.TestCase): def setUp(self): - self.me = Model(EmBackendJson('EditorialModel/test/me.json')) + self.me = Model(EmBackendJson('EditorialModel/test/me.json')) def test_init(self): """ Instanciation test """ model = Model(EmBackendJson('EditorialModel/test/me.json')) self.assertTrue(isinstance(model, Model)) - model = Model(EmBackendJson('EditorialModel/test/me.json'), migration_handler = DummyMigrationHandler(True)) + model = Model(EmBackendJson('EditorialModel/test/me.json'), migration_handler=DjangoMigrationHandler('test',debug=True)) self.assertTrue(isinstance(model, Model)) def test_components(self): @@ -27,41 +28,38 @@ class TestModel(unittest.TestCase): for comp_class in [EmClass, EmType, EmField, EmFieldGroup]: comp_l = self.me.components(comp_class) for component in comp_l: - self.assertTrue(isinstance(component, comp_class), "Model.components method don't return EmComponent of the right type. Asked for {} but got {}".format(type(comp_class), type(component))) + self.assertTrue(isinstance(component, comp_class), "Model.components method doesn't return EmComponent of the right type. Asked for {} but got {}".format(type(comp_class), type(component))) def test_sort_components(self): """ Test that Model.sort_components method actually sort components """ - #disordering an EmClass + # disordering an EmClass cl_l = self.me.components(EmClass) last_class = cl_l[0] last_class.rank = 10000 self.me.sort_components(EmClass) - self.assertEqual(self.me._components['EmClass'][-1].uid, last_class.uid, "The methode sort_components don't really sort by rank") + self.assertEqual(self.me._components['EmClass'][-1].uid, last_class.uid, "The sort_components method doesn't really sort by rank") def test_new_uid(self): - """ Test that Model.new_uid return a new uniq uid """ + """ Test that model.new_uid return a new uniq uid """ new_uid = self.me.new_uid() self.assertNotIn(new_uid, self.me._components['uids'].keys()) - def test_hash(self): - """ Test that __hash__ and __eq__ works properly on models """ - me = Model(EmBackendJson('EditorialModel/test/me.json')) - me2 = Model(EmBackendJson('EditorialModel/test/me.json'), migration_handler = DummyMigrationHandler(True)) + """ Test that __hash__ and __eq__ work properly on models """ + me1 = Model(EmBackendJson('EditorialModel/test/me.json')) + me2 = Model(EmBackendJson('EditorialModel/test/me.json'), migration_handler=DjangoMigrationHandler('test', debug=True)) - self.assertEqual(hash(me), hash(me2), "When instanciate from the same backend & file but with another migration handler the hashes differs") - self.assertTrue(me, me2) + self.assertEqual(hash(me1), hash(me2), "When instanciate from the same backend & file but with another migration handler the hashes differs") + self.assertTrue(me1, me2) - cl_l = me.classes() + cl_l = me1.classes() cl_l[0].modify_rank(1) - self.assertNotEqual(hash(me), hash(me2), "After a class rank modification the hashes are the same") - self.assertFalse(me, me2) + self.assertNotEqual(hash(me1), hash(me2), "After a class rank modification the hashes are the same") + self.assertFalse(me1, me2) cl_l = me2.classes() cl_l[0].modify_rank(1) self.assertEqual(hash(me), hash(me2), "After doing sames modifications in the two models the hashes differs") - self.assertTrue(me, me2) - - + self.assertTrue(me1, me2) \ No newline at end of file