Browse Source

Update datasource tests (deleted test concerning multivalue fields) + add an utility method in DataSource/MySQL/fieldtypes.py

Yann Weber 8 years ago
parent
commit
ec386c3e72
2 changed files with 7 additions and 88 deletions
  1. 7
    2
      DataSource/MySQL/fieldtypes.py
  2. 0
    86
      DataSource/MySQL/test/test_datasource.py

+ 7
- 2
DataSource/MySQL/fieldtypes.py View File

@@ -13,6 +13,7 @@ import EditorialModel.fieldtypes.char
13 13
 import EditorialModel.fieldtypes.bool
14 14
 import EditorialModel.fieldtypes.text
15 15
 import EditorialModel.fieldtypes.rel2type
16
+import EditorialModel.fieldtypes.leo
16 17
 
17 18
 ## @brief Returns column specs from fieldtype
18 19
 # @param emfieldtype EmFieldType : An EmFieldType insance
@@ -73,6 +74,10 @@ def fieldtype_db_init(fieldtype, noauto_inc = False):
73 74
     else:
74 75
         raise NotImplementedError("Not yet implemented")
75 76
     return tuple(res)
76
-            
77
-    
77
+
78
+## @brief Cast a value given a fieldtype
79
+def fieldtype_cast(fieldtype, value):
80
+    if isinstance(fieldtype, EditorialModel.fieldtypes.leo.EmFieldType):
81
+        return value.uidget()
82
+    return value
78 83
 

+ 0
- 86
DataSource/MySQL/test/test_datasource.py View File

@@ -191,92 +191,6 @@ class DataSourceTestCase(TestCase):
191 191
                     'joins':None, #Expected call on Query.__call__ (called when we call left_join)
192 192
                 }
193 193
             ),
194
-            # call Article.select(fields = ['lodel_id', 'titre'], filters = ['lodel_id = 42'])
195
-            (
196
-                {
197
-                    'leobject': [lodel_id],
198
-                    'leclass': ['titre'],
199
-                },
200
-                {
201
-                    'target_cls': Article,
202
-                    'filters': [ (lodel_id, '=', 42) ],
203
-                    'rel_filters': [],
204
-                },
205
-                {
206
-                    'where': {
207
-                        (
208
-                            db_utils.column_prefix(table_names[LeObject], lodel_id),
209
-                            '=',
210
-                        ): 42
211
-                    },
212
-                    'joins': call(
213
-                        table_names[Article],
214
-                        {join_lodel_id: cls_lodel_id(Article)}
215
-                    ),
216
-                }
217
-            ),
218
-            # call Article.select(fields = ['lodel_id', 'titre'], filters = ['lodel_id = 42', 'soustitre = "foobar"'])
219
-            (
220
-                {
221
-                    'leobject': [lodel_id],
222
-                    'leclass': ['titre'],
223
-                },
224
-                {
225
-                    'target_cls': Article,
226
-                    'filters': [
227
-                        (lodel_id, '=', 42),
228
-                        ('soustitre', '=', 'foobar'),
229
-                    ],
230
-                    'rel_filters': [],
231
-                },
232
-                {
233
-                    'where': {
234
-                        (
235
-                            db_utils.column_prefix(table_names[LeObject], lodel_id),
236
-                            '=',
237
-                        ): 42,
238
-                        (
239
-                            db_utils.column_prefix(table_names[Article], 'soustitre'),
240
-                            '=',
241
-                        ): 'foobar',
242
-                    },
243
-                    'joins': call(
244
-                        table_names[Article],
245
-                        {join_lodel_id: cls_lodel_id(Article)}
246
-                    ),
247
-                }
248
-            ),
249
-            # call Textes.select(fields = ['lodel_id', 'titre'], filters = ['lodel_id = 42', 'soustitre = "foobar"'])
250
-            (
251
-                {
252
-                    'leobject': [lodel_id],
253
-                    'leclass': ['titre'],
254
-                },
255
-                {
256
-                    'target_cls': Article,
257
-                    'filters': [
258
-                        (lodel_id, '=', 42),
259
-                        ('soustitre', '=', 'foobar'),
260
-                    ],
261
-                    'rel_filters': [],
262
-                },
263
-                {
264
-                    'where': {
265
-                        (
266
-                            db_utils.column_prefix(table_names[LeObject], lodel_id),
267
-                            '=',
268
-                        ): 42,
269
-                        (
270
-                            db_utils.column_prefix(table_names[Textes], 'soustitre'),
271
-                            '=',
272
-                        ): 'foobar',
273
-                    },
274
-                    'joins': call(
275
-                        table_names[Textes],
276
-                        {join_lodel_id: cls_lodel_id(Textes)}
277
-                    ),
278
-                }
279
-            ),
280 194
         ]
281 195
 
282 196
         # mock the database module to avoid connection tries

Loading…
Cancel
Save