-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtry_allocate.py
More file actions
26 lines (22 loc) · 1.09 KB
/
try_allocate.py
File metadata and controls
26 lines (22 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from app import app
from models import Event, Resource, EventResourceAllocation
with app.app_context():
with app.test_client() as client:
# Pick two events that overlap
events = Event.query.order_by(Event.start_time).all()
resources = Resource.query.all()
e1 = events[0]
e2 = events[1]
r = resources[0]
print('Try allocating resource to first event')
res = client.post('/allocate', data={'event_id': e1.event_id, 'resource_id': r.resource_id}, follow_redirects=True)
print('Status:', res.status_code)
print(res.get_data(as_text=True)[:400])
print('\nAttempt to allocate same resource to overlapping second event')
res2 = client.post('/allocate', data={'event_id': e2.event_id, 'resource_id': r.resource_id}, follow_redirects=True)
print('Status:', res2.status_code)
print(res2.get_data(as_text=True)[:400])
# Show current allocations
allocs = EventResourceAllocation.query.all()
for a in allocs:
print('Alloc:', a.allocation_id, a.event_id, a.resource_id)