Exemple #1
0
def test_add_reserved_slot(scheduler):

    allocation = Allocation(raster=15, resource=scheduler.resource)
    allocation.start = datetime(2011, 1, 1, 15, tzinfo=utc)
    allocation.end = datetime(2011, 1, 1, 15, 59, tzinfo=utc)
    allocation.group = new_uuid().hex
    allocation.mirror_of = scheduler.resource

    reservation = new_uuid()

    slot = ReservedSlot(resource=allocation.resource)
    slot.start = allocation.start
    slot.end = allocation.end
    slot.allocation = allocation
    slot.reservation = reservation

    # Ensure that the same slot cannot be doubly used
    another = ReservedSlot(resource=allocation.resource)
    another.start = allocation.start
    another.end = allocation.end
    another.allocation = allocation
    another.reservation = reservation

    scheduler.session.add(allocation)
    scheduler.session.add(slot)
    scheduler.session.add(another)

    with pytest.raises(IntegrityError):
        scheduler.session.flush()
Exemple #2
0
def add_something(resource=None):
    resource = resource or uuid()
    allocation = Allocation(raster=15, resource=resource, mirror_of=resource)
    allocation.start = datetime(2011, 1, 1, 15)
    allocation.end = datetime(2011, 1, 1, 15, 59)
    allocation.group = uuid()

    Session.add(allocation)
def add_something(resource=None):
    resource = resource or uuid()
    allocation = Allocation(
        raster=15, resource=resource, mirror_of=resource)
    allocation.start = datetime(2011, 1, 1, 15)
    allocation.end = datetime(2011, 1, 1, 15, 59)
    allocation.group = uuid()

    Session.add(allocation)
Exemple #4
0
def test_add_allocation(scheduler):

    allocation = Allocation(raster=15, resource=scheduler.resource)
    allocation.start = datetime(2011, 1, 1, 15, tzinfo=utc)
    allocation.end = datetime(2011, 1, 1, 15, 59, tzinfo=utc)
    allocation.group = new_uuid().hex
    allocation.mirror_of = scheduler.resource

    scheduler.session.add(allocation)
    scheduler.commit()

    assert scheduler.session.query(Allocation).count() == 1