Skip to content

Commit

Permalink
Covering mixins, pylover#182
Browse files Browse the repository at this point in the history
  • Loading branch information
pylover committed Jun 5, 2019
1 parent fda03f9 commit c0093f7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

3 changes: 2 additions & 1 deletion restfulpy/orm/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,9 @@ def return_(e):
not_ = value.startswith('!')
groups = between_operator_match.groupdict()
start, end = groups['min'].strip(), groups['max'].strip()
if not (start or end):
if not (start and end):
raise HTTPBadRequest('Invalid query string: %s' % value)

expression = between(column, start, end)
if not_:
expression = ~expression
Expand Down
9 changes: 9 additions & 0 deletions tests/test_mixin_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ def test_filtering_mixin(db):
with Context({'QUERY_STRING': 'id=BETWEEN(1,3)'}):
assert FilteringObject.filter_by_request(query).count() == 3

# Not Between
with Context({'QUERY_STRING': 'id=!BETWEEN(1,5)'}):
assert FilteringObject.filter_by_request(query).count() == 1

# Bad Between
with pytest.raises(HTTPBadRequest), \
Context({'QUERY_STRING': 'id=BETWEEN(1,)'}):
FilteringObject.filter_by_request(query)

# ==
with Context({'QUERY_STRING': 'id=1'}):
assert FilteringObject.filter_by_request(query).count() == 1
Expand Down

0 comments on commit c0093f7

Please sign in to comment.