0001-storage-add-Not-criteria-6108.patch
tests/test_storage.py | ||
---|---|---|
242 | 242 |
assert len(Foobar.select([st.Less('unique_value', 26)])) == 25 |
243 | 243 |
assert len(Foobar.select([st.Less('unique_value', 25), st.GreaterOrEqual('unique_value', 10)])) == 15 |
244 | 244 |
assert len(Foobar.select([st.NotEqual('unique_value', 25)])) == 49 |
245 |
assert len(Foobar.select([st.Not(st.Equal('unique_value', 25))])) == 49 |
|
245 | 246 |
assert len(Foobar.select([st.Contains('unique_value', [24, 25, 26])])) == 3 |
246 | 247 |
assert len(Foobar.select([st.Contains('unique_value', [24, 25, 86])])) == 2 |
247 | 248 |
assert len(Foobar.select([st.NotContains('unique_value', [24, 25, 86])])) == 48 |
249 |
assert len(Foobar.select([st.Not(st.Contains('unique_value', [24, 25, 86]))])) == 48 |
|
248 | 250 | |
249 | 251 | |
250 | 252 |
def test_select_order_by(): |
... | ... | |
366 | 368 | |
367 | 369 |
assert len(Foobar.select([st.Null('value')])) == 33 |
368 | 370 |
assert len(Foobar.select([st.NotNull('value')])) == 17 |
371 |
assert len(Foobar.select([st.Not(st.Null('value'))])) == 17 |
|
369 | 372 | |
370 | 373 | |
371 | 374 |
def test_select_criteria_ilike(): |
wcs/qommon/storage.py | ||
---|---|---|
216 | 216 |
return func |
217 | 217 | |
218 | 218 | |
219 |
class Not(Criteria): |
|
220 |
def __init__(self, criteria, **kwargs): |
|
221 |
self.criteria = criteria |
|
222 | ||
223 |
def build_lambda(self): |
|
224 |
func = lambda x: False |
|
225 | ||
226 |
def combine_callables(x1, x2): |
|
227 |
return lambda x: not x2(x) |
|
228 | ||
229 |
func = combine_callables(func, self.criteria.build_lambda()) |
|
230 |
return func |
|
231 | ||
232 |
def __repr__(self): |
|
233 |
return '<%s (%r)>' % (self.__class__.__name__, self.criteria) |
|
234 | ||
235 | ||
219 | 236 |
class Or(Criteria): |
220 | 237 |
def __init__(self, criterias, **kwargs): |
221 | 238 |
self.criterias = criterias |
222 |
- |