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

Commit

Permalink
Test start_at and end_at are at midnight
Browse files Browse the repository at this point in the history
  • Loading branch information
phss committed Oct 18, 2013
1 parent 37fa222 commit 4af72c1
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions tests/read/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
from tests.support.validity_matcher import is_invalid_with_message, is_valid


def validate_request_args(request_args):
def validate_request_args(request_args, raw_queries_allowed=True):
if not isinstance(request_args, MultiDict):
request_args = MultiDict(request_args)
return _validate_request_args(request_args, raw_queries_allowed=True)
return _validate_request_args(request_args, raw_queries_allowed)


class TestRequestValidation(TestCase):
Expand Down Expand Up @@ -329,6 +329,27 @@ def test_that_collect_queries_with_invalid_method_are_disallowed(self):
)))


class TestRequestValidationWithNoRawQueries(TestCase):

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

def test_queries_with_dates_at_middle_of_day_are_not_allowed(self):
validation_result = validate_request_args({
'period': 'day',
'start_at': '2000-02-02T12:00:00+00:00',
'end_at': '2000-02-19T13:00:00+00:00'
}, False)
assert_that(validation_result, is_invalid_with_message(
"start_at must be midnight"
))


class TestValidationHelpers(TestCase):
def test_timestamp_is_valid_method(self):
result = validation.value_is_valid_datetime_string(
Expand Down

0 comments on commit 4af72c1

Please sign in to comment.