|
@@ -12,6 +12,7 @@ from EditorialModel.classes import EmClass
|
12
|
12
|
from EditorialModel.classtypes import EmClassType
|
13
|
13
|
from EditorialModel.types import EmType
|
14
|
14
|
from EditorialModel.fieldgroups import EmFieldGroup
|
|
15
|
+from EditorialModel.fields_types import Em_Field_Type
|
15
|
16
|
from EditorialModel.fieldtypes import *
|
16
|
17
|
|
17
|
18
|
from Database.sqlsetup import SQLSetup
|
|
@@ -63,6 +64,35 @@ class FieldTestCase(TestCase):
|
63
|
64
|
|
64
|
65
|
pass
|
65
|
66
|
|
|
67
|
+
|
|
68
|
+ ## Get_Field_Type_Record (Function)
|
|
69
|
+ #
|
|
70
|
+ # Returns associations between field and type from the em_field_type table
|
|
71
|
+ #
|
|
72
|
+ # @param field EmField: Field object
|
|
73
|
+ # @param type EmType: Type object
|
|
74
|
+ # @return list of found associations
|
|
75
|
+ def get_field_type_record(self, field, type):
|
|
76
|
+ return self._get_field_type_record_Db(field, type)
|
|
77
|
+
|
|
78
|
+ ## _Get_Field_Type_Record_Db (Function)
|
|
79
|
+ #
|
|
80
|
+ # Queries the database to get the record from the em_field_type table corresponding to a given field and type
|
|
81
|
+ # @param field EmField: Field object
|
|
82
|
+ # @param type EmType: Type object
|
|
83
|
+ # @return found associations
|
|
84
|
+ def _get_field_type_record_Db(self, field, type):
|
|
85
|
+ sqlwrapper = SqlWrapper(read_db='default', write_db='default', alchemy_logs=False)
|
|
86
|
+ sql_builder = SqlQueryBuilder(sql_wrapper, 'em_field_type')
|
|
87
|
+ sql_builder.Select().From('em_field_type').Where('em_field_type.field_id=%s' % field.uid).Where('em_field_type.type_id=%s' % type.uid)
|
|
88
|
+ records = sql_builder.Execute().fetchall()
|
|
89
|
+ field_type_records = []
|
|
90
|
+ for record in records:
|
|
91
|
+ field_type_records.append(dict(zip(record.keys(),record)))
|
|
92
|
+
|
|
93
|
+ return field_type_records
|
|
94
|
+
|
|
95
|
+
|
66
|
96
|
## Get_Field_Records (Function)
|
67
|
97
|
#
|
68
|
98
|
# Returns the list of fields corresponding to a given uid
|
|
@@ -143,3 +173,16 @@ class TestField(FieldTestCase):
|
143
|
173
|
self.assertIn(field_column,field_table_columns)
|
144
|
174
|
pass
|
145
|
175
|
|
|
176
|
+
|
|
177
|
+ ## Test_Select (Function)
|
|
178
|
+ #
|
|
179
|
+ # The selected field has a record in the em_field_type table
|
|
180
|
+ def testSelectField(self):
|
|
181
|
+ testType = EmType.create('testtype2',self.testClass)
|
|
182
|
+
|
|
183
|
+ field=EmField('testfield1')
|
|
184
|
+ field.select_field('testtype2')
|
|
185
|
+
|
|
186
|
+ field_type_object = Em_Field_Type(testType.uid, field.uid)
|
|
187
|
+ self.assertEqual(field_type_object.exists(),True)
|
|
188
|
+ pass
|