def test_em_test(self): """ Testing xmlfile with the test editorial model """ emmodel = picklefile.load(Settings.editorialmodel.emfile) emmodel.save(xmlfile, filename=self.tmpfile) emmodel.save(xmlfile, filename='empick.xml') emmodel_loaded = xmlfile.load(self.tmpfile) emmodel_loaded.save(xmlfile, filename='empick2.xml')
def test_groups(self): """ Testing xmlfile groups handling """ emmodel = EditorialModel("em_test", description="test model") emmodel.new_group('test_grp', display_name="Test group") emmodel.save(xmlfile, filename=self.tmpfile) emmodel_loaded = xmlfile.load(self.tmpfile) self.assertEqual(emmodel.d_hash(), emmodel_loaded.d_hash())
def test_abstract_classes(self): """ Testing xmlfile abtract class handling """ emmodel = EditorialModel("em_test", description="Test model") cls1 = emmodel.new_class('testclass1', display_name="test class 1", abstract=True) emmodel.save(xmlfile, filename=self.tmpfile) emmodel_loaded = xmlfile.load(self.tmpfile) self.assertEqual(emmodel.d_hash(), emmodel_loaded.d_hash())
def test_emfield_with_prop_bool(self): """ Testing xmlfile with bool as property for datahandler """ emmodel = EditorialModel("em_test", description="test model") cls1 = emmodel.new_class('testclass1', display_name="test class 1") cls1f1 = cls1.new_field('testfield1', data_handler='varchar', nullable=True) emmodel.save(xmlfile, filename=self.tmpfile) emmodel_loaded = xmlfile.load(self.tmpfile) self.assertEqual(emmodel.d_hash(), emmodel_loaded.d_hash())
def test_emclass_with_ml_strings(self): """ Testing xmlfile mlstring handling in classes""" emmodel = EditorialModel("em_test", description="test model") cls1 = emmodel.new_class('testclass1', display_name={ 'eng': "test class 1", 'fre': 'classe de test 1' }) emmodel.save(xmlfile, filename=self.tmpfile) emmodel_loaded = xmlfile.load(self.tmpfile) self.assertEqual(emmodel.d_hash(), emmodel_loaded.d_hash())
def test_groups_dependencies(self): """ Testing xmlfile groups population dependencies """ emmodel = EditorialModel("em_test", description="test model") grp1 = emmodel.new_group('test_grp', display_name="Test group") grp2 = emmodel.new_group('test_grp2', display_name="Test group2") grp3 = emmodel.new_group('test_grp3', display_name="Test group3", depends=[grp1, grp2]) emmodel.save(xmlfile, filename=self.tmpfile) emmodel_loaded = xmlfile.load(self.tmpfile) self.assertEqual(emmodel.d_hash(), emmodel_loaded.d_hash())
def test_emfield_with_ml_strings(self): """ Testing xmlfile mlstring handling in data handlers """ emmodel = EditorialModel("em_test", description="test model") cls1 = emmodel.new_class('testclass1', display_name="test class 1") cls1f1 = cls1.new_field('testfield1', display_name={ 'eng': 'test1', 'fre': 'test1' }, data_handler='varchar') emmodel.save(xmlfile, filename=self.tmpfile) emmodel_loaded = xmlfile.load(self.tmpfile) self.assertEqual(emmodel.d_hash(), emmodel_loaded.d_hash())
def test_groups_population(self): """ Testing xmlfile groups population handling """ emmodel = EditorialModel("em_test", description="test model") cls1 = emmodel.new_class('testclass1', display_name="test class 1") cls2 = emmodel.new_class('testclass2', display_name="test class 2") cls1f1 = cls1.new_field('testfield1', data_handler='varchar') cls2f1 = cls2.new_field('testfield2', data_handler='varchar') cls2f2 = cls2.new_field('testfield3', data_handler='varchar') grp1 = emmodel.new_group('test_grp', display_name="Test group") grp2 = emmodel.new_group('test_grp2', display_name="Test group2") grp1.add_components([cls1, cls2]) grp2.add_components([cls1f1, cls2f1, cls2f2]) emmodel.save(xmlfile, filename=self.tmpfile) emmodel_loaded = xmlfile.load(self.tmpfile) self.assertEqual(emmodel.d_hash(), emmodel_loaded.d_hash())
def test_emfield_with_prop_tuple(self): """ Testing xmlfile with iterable as property for datahandler """ emmodel = EditorialModel("em_test", description="test model") cls1 = emmodel.new_class('testclass1', display_name="test class 1") cls2 = emmodel.new_class('testclass2', display_name="test class 2") cls1f1 = cls1.new_field('testfield1', data_handler='varchar') cls2f1 = cls2.new_field('testfield2', data_handler='list', allowed_classes=[cls1, cls2]) cls2f1 = cls2.new_field('testfield3', data_handler='varchar', back_reference=('testclass2', 'testfield1')) emmodel.save(xmlfile, filename=self.tmpfile) emmodel_loaded = xmlfile.load(self.tmpfile) self.assertEqual(emmodel.d_hash(), emmodel_loaded.d_hash())