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

Commit

Permalink
For hour period, don't check 7 day timespan
Browse files Browse the repository at this point in the history
  • Loading branch information
phss committed Oct 18, 2013
1 parent d7572d6 commit aa4da37
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion backdrop/read/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ def validate(self, request_args, context):

def _is_valid_date_query(self, request_args):
return _is_valid_date(request_args.get('start_at')) \
and _is_valid_date(request_args.get('end_at'))
and _is_valid_date(request_args.get('end_at')) \
and request_args.get('period') != 'hour'


class MidnightValidator(Validator):
Expand Down
8 changes: 8 additions & 0 deletions tests/read/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,14 @@ def test_queries_spanning_less_than_seven_days_are_not_allowed(self):
"The minimum time span for a query is 7 days"
))

def test_queries_for_hour_period_spanning_less_than_seven_days_are_allowed(self):
validation_result = validate_request_args({
'period': 'hour',
'start_at': '2000-02-02T00:00:00+00:00',
'end_at': '2000-02-08T00:00:00+00:00'
}, False)
assert_that(validation_result, is_valid())


class TestValidationHelpers(TestCase):
def test_timestamp_is_valid_method(self):
Expand Down

0 comments on commit aa4da37

Please sign in to comment.