Exemple #1
0
def test_reservation_form_quota():
    allocation = Allocation()

    allocation.quota = 1
    allocation.quota_limit = 1
    form = ReservationForm.for_allocation(allocation)()
    assert not hasattr(form, 'quota')

    allocation.quota = 2
    allocation.quota_limit = 1
    form = ReservationForm.for_allocation(allocation)()
    assert not hasattr(form, 'quota')

    allocation.quota = 1
    allocation.quota_limit = 2
    form = ReservationForm.for_allocation(allocation)()
    assert not hasattr(form, 'quota')

    allocation.quota = 2
    allocation.quota_limit = 2
    form = ReservationForm.for_allocation(allocation)()
    assert hasattr(form, 'quota')

    allocation.quota = 2
    allocation.quota_limit = 0
    form = ReservationForm.for_allocation(allocation)()
    assert hasattr(form, 'quota')