Exemplo n.º 1
0
def test_daterange_property():
    daterange_span = daterange.from_date(date(2000, 1, 1), period="month")
    span = PeriodRange.from_date(date(2000, 1, 1), period="month")

    assert type(span.daterange) is daterange
    assert daterange_span == span.daterange
Exemplo n.º 2
0
def test_from_date_type_check(param):
    with pytest.raises(TypeError):
        daterange.from_date(param)
Exemplo n.º 3
0
def test_from_date_period_check(period):
    with pytest.raises(ValueError):
        daterange.from_date(date(2000, 1, 1), period=period)
Exemplo n.º 4
0
def test_from_date_quarter(day, span):
    assert daterange.from_date(day, period="quarter") == span
Exemplo n.º 5
0
def test_from_date_year(day, span):
    assert daterange.from_date(day, period="year") == span
Exemplo n.º 6
0
def test_from_date_american_week(day, span):
    assert daterange.from_date(day, period="american_week") == span
Exemplo n.º 7
0
def test_from_date_month(day, span):
    assert daterange.from_date(day, period="month") == span
Exemplo n.º 8
0
def test_from_date():
    date_start = date(2000, 1, 1)
    assert daterange.from_date(date_start) == \
        daterange(date_start, date_start + timedelta(1))
Exemplo n.º 9
0
def test_from_year(year):
    assert daterange.from_year(year) == daterange.from_date(
        date(year, 1, 1), period="year")
Exemplo n.º 10
0
def test_from_quarter(year, quarter, first_day):
    assert daterange.from_quarter(year, quarter) == daterange.from_date(
        first_day, period="quarter")
Exemplo n.º 11
0
def test_from_month(year, month):
    assert daterange.from_month(year, month) == daterange.from_date(
        date(year, month, 1), period="month")
Exemplo n.º 12
0
def test_from_week(year, iso_week, first_day):
    assert daterange.from_week(year, iso_week) == daterange.from_date(
        first_day, period="week")