301 label_variable = 'OL' |
301 label_variable = 'OL' |
302 self.assertRaises(AssertionError, RPF, req, rset=rset, |
302 self.assertRaises(AssertionError, RPF, req, rset=rset, |
303 select=rqlst.children[0], |
303 select=rqlst.children[0], |
304 filtered_variable=filtered_variable) |
304 filtered_variable=filtered_variable) |
305 |
305 |
|
306 |
|
307 def test_rqlpath_range(self): |
|
308 req, rset, rqlst, filtered_variable = self.prepare_rqlst() |
|
309 class RRF(facet.DateRangeRQLPathFacet): |
|
310 path = [('X created_by U'), ('U owned_by O'), ('O creation_date OL')] |
|
311 filter_variable = 'OL' |
|
312 f = RRF(req, rset=rset, select=rqlst.children[0], |
|
313 filtered_variable=filtered_variable) |
|
314 mind, maxd = self.execute('Any MIN(CD), MAX(CD) WHERE X is CWUser, X created_by U, U owned_by O, O creation_date CD')[0] |
|
315 self.assertEqual(f.vocabulary(), [(str(mind), mind), |
|
316 (str(maxd), maxd)]) |
|
317 # ensure rqlst is left unmodified |
|
318 self.assertEqual(rqlst.as_string(), 'DISTINCT Any WHERE X is CWUser') |
|
319 self.assertEqual(f.possible_values(), |
|
320 [str(mind), str(maxd)]) |
|
321 # ensure rqlst is left unmodified |
|
322 self.assertEqual(rqlst.as_string(), 'DISTINCT Any WHERE X is CWUser') |
|
323 req.form['%s_inf' % f.__regid__] = str(datetime2ticks(mind)) |
|
324 req.form['%s_sup' % f.__regid__] = str(datetime2ticks(mind)) |
|
325 f.add_rql_restrictions() |
|
326 # selection is cluttered because rqlst has been prepared for facet (it |
|
327 # is not in real life) |
|
328 self.assertEqual(f.select.as_string(), |
|
329 'DISTINCT Any WHERE X is CWUser, X created_by G, G owned_by H, H creation_date >= "%s", ' |
|
330 'H creation_date <= "%s"' |
|
331 % (mind.strftime('%Y/%m/%d'), |
|
332 mind.strftime('%Y/%m/%d'))) |
|
333 |
306 def prepareg_aggregat_rqlst(self): |
334 def prepareg_aggregat_rqlst(self): |
307 return self.prepare_rqlst( |
335 return self.prepare_rqlst( |
308 'Any 1, COUNT(X) WHERE X is CWUser, X creation_date XD, ' |
336 'Any 1, COUNT(X) WHERE X is CWUser, X creation_date XD, ' |
309 'X modification_date XM, Y creation_date YD, Y is CWGroup ' |
337 'X modification_date XM, Y creation_date YD, Y is CWGroup ' |
310 'HAVING DAY(XD)>=DAY(YD) AND DAY(XM)<=DAY(YD)', 'X', |
338 'HAVING DAY(XD)>=DAY(YD) AND DAY(XM)<=DAY(YD)', 'X', |