|
@@ -4,6 +4,7 @@ from unittest import TestCase
|
4
|
4
|
from EditorialModel.fields import EmField
|
5
|
5
|
from EditorialModel.model import Model
|
6
|
6
|
from EditorialModel.backend.json_backend import EmBackendJson
|
|
7
|
+from EditorialModel.exceptions import EmComponentCheckError
|
7
|
8
|
|
8
|
9
|
EM_TEST = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'me.json')
|
9
|
10
|
EM_TEST_OBJECT = None
|
|
@@ -62,6 +63,30 @@ class TestField(FieldTestCase):
|
62
|
63
|
with self.assertRaises(ValueError, msg="Only common_fields should be internal='object'"):
|
63
|
64
|
field = EM_TEST_OBJECT.create_component(EmField.__name__, {'name': 'testbadinternal','internal': 'object', 'fieldgroup_id': self.test_fieldgroup.uid, 'fieldtype': self.test_fieldtype})
|
64
|
65
|
|
|
66
|
+ def test_double_rel2type(self):
|
|
67
|
+ """ Test the rel2type unicity """
|
|
68
|
+ em = EM_TEST_OBJECT
|
|
69
|
+ emtype = em.components('EmType')[0]
|
|
70
|
+ emclass = [c for c in em.components('EmClass') if c != emtype.em_class][0]
|
|
71
|
+
|
|
72
|
+ f1 = em.create_component('EmField', {'name': 'testr2t', 'fieldgroup_id': emclass.fieldgroups()[0].uid, 'fieldtype': 'rel2type', 'rel_to_type_id': emtype.uid})
|
|
73
|
+
|
|
74
|
+ with self.assertRaises(EmComponentCheckError):
|
|
75
|
+ f2 = em.create_component('EmField', {'name': 'testr2t2', 'fieldgroup_id': emclass.fieldgroups()[0].uid, 'fieldtype': 'rel2type', 'rel_to_type_id': emtype.uid})
|
|
76
|
+
|
|
77
|
+ def test_same_name(self):
|
|
78
|
+ """ Test the name unicity is the same EmClass"""
|
|
79
|
+ em = EM_TEST_OBJECT
|
|
80
|
+ emtype = em.components('EmType')[0]
|
|
81
|
+ emclass = [c for c in em.components('EmClass') if c != emtype.em_class][0]
|
|
82
|
+
|
|
83
|
+ f1 = em.create_component('EmField', {'name': 'samename', 'fieldgroup_id': emclass.fieldgroups()[0].uid, 'fieldtype': 'char'})
|
|
84
|
+
|
|
85
|
+ with self.assertRaises(EmComponentCheckError):
|
|
86
|
+ f2 = em.create_component('EmField', {'name': 'samename', 'fieldgroup_id': emclass.fieldgroups()[1].uid, 'fieldtype': 'integer'} )
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
65
|
90
|
## Test_Deletion
|
66
|
91
|
#
|
67
|
92
|
# tests the deletion process of a field
|