Browse Source

Add a test_query to the datasource select test method

The query is something like Textes.select(fields = ['lodel_id', 'titre'], filters = ['lodel_id = 42', 'soustitre = "foobar"'])
Yann Weber 9 years ago
parent
commit
1782153774
1 changed files with 33 additions and 1 deletions
  1. 33
    1
      DataSource/MySQL/test/test_datasource.py

+ 33
- 1
DataSource/MySQL/test/test_datasource.py View File

124
 
124
 
125
     def test_select_leobject(self):
125
     def test_select_leobject(self):
126
         """ Test select method on leobject without relational filters """
126
         """ Test select method on leobject without relational filters """
127
-        from dyncode import Article, Personne, Rubrique, LeObject
127
+        from dyncode import LeObject, Article, Textes
128
         
128
         
129
         # Utils var and stuff to make tests queries write easier
129
         # Utils var and stuff to make tests queries write easier
130
         
130
         
134
         table_names = {
134
         table_names = {
135
             LeObject: db_utils.objects_table_name,
135
             LeObject: db_utils.objects_table_name,
136
             Article: db_utils.get_table_name_from_class(Article._leclass.__name__),
136
             Article: db_utils.get_table_name_from_class(Article._leclass.__name__),
137
+            Textes: db_utils.get_table_name_from_class(Textes.__name__),
137
         }
138
         }
138
         # lodel_id name to be use in joins (leobject side)
139
         # lodel_id name to be use in joins (leobject side)
139
         join_lodel_id = db_utils.column_prefix(table_names[LeObject], lodel_id)
140
         join_lodel_id = db_utils.column_prefix(table_names[LeObject], lodel_id)
248
                     ),
249
                     ),
249
                 }
250
                 }
250
             ),
251
             ),
252
+            # call Textes.select(fields = ['lodel_id', 'titre'], filters = ['lodel_id = 42', 'soustitre = "foobar"'])
253
+            (
254
+                {
255
+                    'leobject': [lodel_id],
256
+                    'leclass': ['titre'],
257
+                },
258
+                {
259
+                    'target_cls': Article,
260
+                    'filters': [
261
+                        (lodel_id, '=', 42),
262
+                        ('soustitre', '=', 'foobar'),
263
+                    ],
264
+                    'rel_filters': [],
265
+                },
266
+                {
267
+                    'where': {
268
+                        (
269
+                            db_utils.column_prefix(table_names[LeObject], lodel_id),
270
+                            '=',
271
+                        ): 42,
272
+                        (
273
+                            db_utils.column_prefix(table_names[Textes], 'soustitre'),
274
+                            '=',
275
+                        ): 'foobar',
276
+                    },
277
+                    'joins': call(
278
+                        table_names[Textes],
279
+                        {join_lodel_id: cls_lodel_id(Textes)}
280
+                    ),
281
+                }
282
+            ),
251
         ]
283
         ]
252
 
284
 
253
         # mock the database module to avoid connection tries
285
         # mock the database module to avoid connection tries

Loading…
Cancel
Save