|
@@ -0,0 +1,60 @@
|
|
1
|
+import os
|
|
2
|
+import logging
|
|
3
|
+import datetime
|
|
4
|
+
|
|
5
|
+from django.conf import settings
|
|
6
|
+from unittest import TestCase
|
|
7
|
+import unittest
|
|
8
|
+
|
|
9
|
+from EditorialModel.types import EmType
|
|
10
|
+from EditorialModel.classes import EmClass
|
|
11
|
+from EditorialModel.classtypes import EmClassType
|
|
12
|
+from EditorialModel.components import EmComponent
|
|
13
|
+from EditorialModel.fieldgroups import EmFieldGroup
|
|
14
|
+from EditorialModel.fieldtypes import *
|
|
15
|
+from EditorialModel.fields_types import Em_Field_Type
|
|
16
|
+from EditorialModel.fields import EmField
|
|
17
|
+from EditorialModel.test.utils import *
|
|
18
|
+from Database import sqlutils
|
|
19
|
+
|
|
20
|
+import sqlalchemy as sqla
|
|
21
|
+
|
|
22
|
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "Lodel.settings")
|
|
23
|
+TEST_TYPE_DBNAME = 'test_em_type_db.sqlite'
|
|
24
|
+
|
|
25
|
+def setUpModule():
|
|
26
|
+ logging.basicConfig(level=logging.CRITICAL)
|
|
27
|
+
|
|
28
|
+ initTestDb(TEST_TYPE_DBNAME)
|
|
29
|
+ setDbConf(TEST_TYPE_DBNAME)
|
|
30
|
+
|
|
31
|
+ saveDbState(TEST_TYPE_DBNAME)
|
|
32
|
+
|
|
33
|
+def tearDownModule():
|
|
34
|
+ cleanDb(TEST_TYPE_DBNAME)
|
|
35
|
+ pass
|
|
36
|
+
|
|
37
|
+class TypeTestCase(TestCase):
|
|
38
|
+
|
|
39
|
+ def setUp(self):
|
|
40
|
+
|
|
41
|
+ self.emclass1 = EmClass.create("entity1", EmClassType.entity)
|
|
42
|
+ self.emclass2 = EmClass.create("entity2", EmClassType.entity)
|
|
43
|
+
|
|
44
|
+ self.emtype = EmType.create('type1',self.emclass2)
|
|
45
|
+ self.emfieldgroup = EmFieldGroup.create('fieldgroup1',self.emclass1)
|
|
46
|
+ self.emfieldtype = get_field_type('integer')
|
|
47
|
+ self.emfield = EmField.create(name='field1', fieldgroup=self.emfieldgroup, fieldtype=self.emfieldtype, rel_to_type_id=self.emtype.uid)
|
|
48
|
+
|
|
49
|
+ restoreDbState(TEST_TYPE_DBNAME)
|
|
50
|
+ pass
|
|
51
|
+
|
|
52
|
+class TestSelectField(TypeTestCase):
|
|
53
|
+ def testSelectField(self):
|
|
54
|
+ self.emtype.select_field(self.emfield)
|
|
55
|
+ self.assertIsNotNone(Em_Field_Type(self.emtype.uid, self.emfield.uid))
|
|
56
|
+
|
|
57
|
+ def testUnselectField(self):
|
|
58
|
+ self.emtype.unselect_field(self.emfield)
|
|
59
|
+ self.assertFalse(Em_Field_Type(self.emtype.uid, self.emfield.uid).exists())
|
|
60
|
+
|