|
@@ -124,7 +124,7 @@ class DataSourceTestCase(TestCase):
|
124
|
124
|
|
125
|
125
|
def test_select_leobject(self):
|
126
|
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
|
129
|
# Utils var and stuff to make tests queries write easier
|
130
|
130
|
|
|
@@ -134,6 +134,7 @@ class DataSourceTestCase(TestCase):
|
134
|
134
|
table_names = {
|
135
|
135
|
LeObject: db_utils.objects_table_name,
|
136
|
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
|
139
|
# lodel_id name to be use in joins (leobject side)
|
139
|
140
|
join_lodel_id = db_utils.column_prefix(table_names[LeObject], lodel_id)
|
|
@@ -248,6 +249,37 @@ class DataSourceTestCase(TestCase):
|
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
|
285
|
# mock the database module to avoid connection tries
|