Skip to content

Commit

Permalink
Migrate partly test
Browse files Browse the repository at this point in the history
  • Loading branch information
href committed Nov 25, 2014
1 parent 136626b commit 255606e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions libres/tests/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -898,3 +898,39 @@ def test_allocation_partition(scheduler):
assert partitions[1][1] == True
assert partitions[2][0] == 50.00
assert partitions[2][1] == False


def test_partly(scheduler):
allocations = scheduler.allocate(
(
datetime(2011, 1, 1, 8, 0),
datetime(2011, 1, 1, 18, 0)
),
partly_available=False,
approve_manually=False
)

assert len(allocations) == 1
allocation = allocations[0]

assert len(list(allocation.all_slots())) == 1
assert len(list(allocation.free_slots())) == 1

slot = list(allocation.all_slots())[0]
assert slot[0] == allocation.start
assert slot[1] == allocation.end

slot = list(allocation.free_slots())[0]
assert slot[0] == allocation.start
assert slot[1] == allocation.end

token = scheduler.reserve(
u'info@example.org',
(datetime(2011, 1, 1, 16, 0), datetime(2011, 1, 1, 18, 0))
)
scheduler.approve_reservations(token)

with pytest.raises(errors.AlreadyReservedError):
scheduler.reserve(u'info@example.org', (
datetime(2011, 1, 1, 8, 0), datetime(2011, 1, 1, 9, 0)
))

0 comments on commit 255606e

Please sign in to comment.