コード例 #1
0
ファイル: test_forms.py プロジェクト: i18nHub/onegov.town
def test_reservation_form_partly_available():
    allocation = Allocation()

    allocation.timezone = 'Europe/Zurich'
    allocation.start = datetime(2015, 1, 1, 10)
    allocation.end = datetime(2015, 1, 1, 16)

    allocation.partly_available = True
    form = ReservationForm.for_allocation(allocation)()
    assert hasattr(form, 'start')
    assert hasattr(form, 'end')
    assert form.start.default == time(10, 00)
    assert form.end.default == time(16, 00)

    allocation.partly_available = False
    form = ReservationForm.for_allocation(allocation)()
    assert not hasattr(form, 'start')
    assert not hasattr(form, 'end')
コード例 #2
0
ファイル: test_allocation.py プロジェクト: seantis/libres
def test_date_functions(scheduler):
    allocation = Allocation(raster=60, resource=scheduler.resource)
    allocation.timezone = 'UTC'
    allocation.start = datetime(2011, 1, 1, 12, 30, tzinfo=utc)
    allocation.end = datetime(2011, 1, 1, 14, 00, tzinfo=utc)

    assert allocation.start.hour == 12
    assert allocation.start.minute == 0
    assert allocation.end.hour == 13
    assert allocation.end.minute == 59

    start = datetime(2011, 1, 1, 11, 00)
    end = datetime(2011, 1, 1, 12, 5)

    assert allocation.overlaps(start, end)
    assert not allocation.contains(start, end)

    start = datetime(2011, 1, 1, 13, 00)
    end = datetime(2011, 1, 1, 15, 00)

    assert allocation.overlaps(start, end)
    assert not allocation.contains(start, end)