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

Commit

Permalink
WIP: Query changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tombooth committed Jan 9, 2014
1 parent fecaded commit 4f0d87d
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/read/test_parse_request_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from hamcrest import *
import pytz
from werkzeug.datastructures import MultiDict
from freezegun import freeze_time

from backdrop.read.query import parse_request_args

Expand Down Expand Up @@ -142,3 +143,33 @@ def test_one_collect_is_parsed_with_custom_method(self):
args = parse_request_args(request_args)

assert_that(args['collect'], is_([("some_key", "mean")]))

@freeze_time('2014-01-09 00:00:00')
def test_now_and_negative_delta_sets_start_end_window(self):
request_args = MultiDict([
('period', 'day'),
('delta', -3),
])

args = parse_request_args(request_args)

assert_that(args['start_at'], is_(
datetime(2014, 1, 6, 0, 0, 0, tzinfo=pytz.UTC)))

assert_that(args['end_at'], is_(
datetime(2014, 1, 9, 0, 0, 0, tzinfo=pytz.UTC)))

@freeze_time('2014-01-09 00:00:00')
def test_now_and_positive_delta_sets_start_end_window(self):
request_args = MultiDict([
('period', 'day'),
('delta', 3),
])

args = parse_request_args(request_args)

assert_that(args['start_at'], is_(
datetime(2014, 1, 9, 0, 0, 0, tzinfo=pytz.UTC)))

assert_that(args['end_at'], is_(
datetime(2014, 1, 12, 0, 0, 0, tzinfo=pytz.UTC)))

0 comments on commit 4f0d87d

Please sign in to comment.