123 # selection is cluttered because rqlst has been prepared for facet (it |
124 # selection is cluttered because rqlst has been prepared for facet (it |
124 # is not in real life) |
125 # is not in real life) |
125 self.assertEqual(f.select.as_string(), |
126 self.assertEqual(f.select.as_string(), |
126 "DISTINCT Any WHERE X is CWUser, X in_group E, E name 'guests'") |
127 "DISTINCT Any WHERE X is CWUser, X in_group E, E name 'guests'") |
127 |
128 |
|
129 def test_daterange(self): |
|
130 req, rset, rqlst, filtered_variable = self.prepare_rqlst() |
|
131 f = facet.DateRangeFacet(req, rset=rset, |
|
132 select=rqlst.children[0], |
|
133 filtered_variable=filtered_variable) |
|
134 f.rtype = 'creation_date' |
|
135 dates = self.execute('Any CD ORDERBY CD WHERE X is CWUser, X creation_date CD') |
|
136 self.assertEqual(f.vocabulary(), |
|
137 [(str(dates[0][0]), dates[0][0]), |
|
138 (str(dates[1][0]), dates[1][0])]) |
|
139 # ensure rqlst is left unmodified |
|
140 self.assertEqual(rqlst.as_string(), 'DISTINCT Any WHERE X is CWUser') |
|
141 #rqlst = rset.syntax_tree() |
|
142 self.assertEqual(f.possible_values(), |
|
143 [str(dates[0][0]), str(dates[1][0])]) |
|
144 # ensure rqlst is left unmodified |
|
145 self.assertEqual(rqlst.as_string(), 'DISTINCT Any WHERE X is CWUser') |
|
146 req.form['%s_inf' % f.__regid__] = str(datetime2ticks(dates[0][0])) |
|
147 req.form['%s_sup' % f.__regid__] = str(datetime2ticks(dates[0][0])) |
|
148 f.add_rql_restrictions() |
|
149 # selection is cluttered because rqlst has been prepared for facet (it |
|
150 # is not in real life) |
|
151 self.assertEqual(f.select.as_string(), |
|
152 'DISTINCT Any WHERE X is CWUser, X creation_date >= "%s", ' |
|
153 'X creation_date <= "%s"' |
|
154 % (dates[0][0].strftime('%Y/%m/%d'), |
|
155 dates[0][0].strftime('%Y/%m/%d'))) |
128 |
156 |
129 def test_attribute(self): |
157 def test_attribute(self): |
130 req, rset, rqlst, filtered_variable = self.prepare_rqlst() |
158 req, rset, rqlst, filtered_variable = self.prepare_rqlst() |
131 f = facet.AttributeFacet(req, rset=rset, |
159 f = facet.AttributeFacet(req, rset=rset, |
132 select=rqlst.children[0], |
160 select=rqlst.children[0], |