Skip to content
This repository has been archived by the owner on Mar 28, 2019. It is now read-only.

Commit

Permalink
Merge 19d4f3f into 9fd3146
Browse files Browse the repository at this point in the history
  • Loading branch information
leplatrem committed Jan 26, 2015
2 parents 9fd3146 + 19d4f3f commit b192fb0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion readinglist/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ def _extract_filters(self, queryparams):
if param in self.known_fields:
filters.append((param, value, '=='))
if param == '_since':
filters.append((self.modified_field, value, '>='))
if isinstance(value, six.integer_types):
filters.append((self.modified_field, value, '>='))
else:
error_msg = 'Invalid value for _since'
self.request.errors.add('querystring', param, error_msg)

return filters

Expand Down
9 changes: 9 additions & 0 deletions readinglist/tests/test_views_article.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ def test_string_filters_naively_by_value(self):
resp = self.app.get('/articles?title=MoFo', headers=self.headers)
self.assertEqual(len(resp.json['items']), 6)

def test_filter_considers_string_if_syntaxically_invalid(self):
url = '/articles?status=1.2.3'
resp = self.app.get(url, headers=self.headers)
self.assertEqual(len(resp.json['items']), 0)


class ArticleFilterModifiedTest(BaseWebTest, unittest.TestCase):

Expand All @@ -104,6 +109,10 @@ def test_filter_works_with_empty_list(self):
}
self.app.get('/articles?unread=true', headers=self.headers)

def test_filter_with_since_rejects_non_numeric_value(self):
url = '/articles?_since=1.2'
self.app.get(url, headers=self.headers, status=400)


class ArticleSortingTest(BaseWebTest, unittest.TestCase):
def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion readinglist/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def native_value(value):
value = False
try:
return ast.literal_eval(value)
except ValueError:
except (ValueError, SyntaxError):
return value


Expand Down

0 comments on commit b192fb0

Please sign in to comment.