def test_period_range():
    range = period_range(date(2013, 4, 1), date(2013, 4, 7))
    assert_that(range, only_contains(
        (date(2013, 4, 1), date(2013, 4, 7))
    ))

    another_range = period_range(date(2013, 4, 1), date(2013, 4, 21))
    assert_that(another_range, only_contains(
        (date(2013, 4, 1), date(2013, 4, 7)),
        (date(2013, 4, 8), date(2013, 4, 14)),
        (date(2013, 4, 15), date(2013, 4, 21)),
    ))
Exemplo n.º 2
0
def query_for_range(client, query, period_start, period_end):
    items = []
    for start, end in period_range(period_start, period_end):
        items += [
            (start, item) for item in query_ga(client, query, start, end)]

    return items
Exemplo n.º 3
0
def query_for_range(client, query, period_start, period_end):
    items = []
    extend = items.extend

    for start, end in period_range(period_start, period_end):
        extend(query_ga(client, query, start, end))

    return items
def test_period_range_returns_the_containing_week_when_start_equals_end():
    range = period_range(date(2013, 4, 8), date(2013, 4, 8))
    assert_that(range, only_contains(
        (date(2013, 4, 8), date(2013, 4, 14))
    ))
def test_period_range_fails_when_end_is_before_start():
    list(period_range(date(2013, 4, 8), date(2013, 4, 1)))
def test_period_range_defaults_to_a_week_ago():
    range = period_range(None, None)
    assert_that(range, only_contains(
        (date(2013, 4, 1), date(2013, 4, 7))
    ))
def test_period_range_adjusts_dates():
    range = period_range(date(2013, 4, 3), date(2013, 4, 10))
    assert_that(range, only_contains(
        (date(2013, 4, 1), date(2013, 4, 7)),
        (date(2013, 4, 8), date(2013, 4, 14))
    ))
def test_period_range_between_datetime_and_date():
    range = period_range(datetime(2013, 4, 1), date(2013, 4, 7))
    assert_that(range, only_contains(
        (date(2013, 4, 1), date(2013, 4, 7))
    ))