millis = int(round(time.time() * 1000)) + iter * 86400000 return millis desc = "### create restricted resource ###" res = r.create_resource("restricted", "restricted", "restricted", 3, 0, 1) is_success(desc, res) resource_id1 = get_id(res) desc = "### Create Free Resource ###" res = r.create_resource("free", "free", "free", 2, 0, 1) is_success(desc, res) free_id = get_id(res) desc = "### create 1 to 2 reservation ###" res = r.create_reservation([free_id, resource_id1], get_time(1), get_time(2), "t", "d") is_success(desc, res) reservation_id1 = get_id(res) desc = "### create 1 to 3 reservation #1 ###" res = r.create_reservation([free_id, resource_id1], get_time(1), get_time(3), "t", "d") is_success(desc, res) reservation_id2 = get_id(res) desc = "### Test that resource sharing level can be moved up and down ###" res = r.update_resource(resource_id1, sharing_level=4) is_success(desc, res) res = r.update_resource(resource_id1, sharing_level=2) is_success(desc, res) desc = "### create 1 to 3 reservation on free ###"
res = r.create_resource("restricted2", "restricted2", "restricted", 1, 0, 1) is_success(desc, res) restricted_id2 = get_id(res) desc = '### create free resource ###' res = r.create_resource("free", "free", "free", 1000, 0, 1) is_success(desc, res) free_id = get_id(res) millis = int(round(time.time() * 1000)) + 86400000 millis2 = int(round(time.time() * 1000)) + 2*86400000 millis3 = int(round(time.time() * 1000)) + 3*86400000 millis4 = int(round(time.time() * 1000)) + 4*86400000 desc = '### create reservation on restricted1 ###' res = r.create_reservation([restricted_id1], millis, millis2, 't', 'd') is_success(desc, res) r1_id = get_id(res) desc = '### create reservation on restricted2 and one unrestricted ###' res = r.create_reservation([restricted_id1, free_id], millis+1, millis3, 't', 'd') is_success(desc, res) r2F_id = get_id(res) desc = '### create reservation on both restricted resources ###' res = r.create_reservation([restricted_id2, restricted_id1], millis, millis4, 't', 'd') is_success(desc, res) r2r1_id = get_id(res) desc = "### test that resource cannot be changed to free while oversubscribed ###" res = r.update_resource(restricted_id1, "s", "s", "free")
session_response = r.login_to_session('rahul', 'rahul123') test_print(desc, session_response.status_code < 300) rahul_session = session_response.cookies r.session = rahul_session millis = int(round(time.time() * 1000)) + 86400000 millis2 = int(round(time.time() * 1000)) + 2*86400000 millis3 = int(round(time.time() * 1000)) + 3*86400000 millis4 = int(round(time.time() * 1000)) + 4*86400000 millis5 = int(round(time.time() * 1000)) + 5*86400000 millis6 = int(round(time.time() * 1000)) + 6*86400000 millis7 = int(round(time.time() * 1000)) + 7*86400000 millis8 = int(round(time.time() * 1000)) + 8*86400000 desc = '#### create reservation for rahul on resource1 ####' res = r.create_reservation([resource_id1], millis, millis2, 'title', 'description') test_print(desc, res.status_code < 300) desc = '#### create reservation for rahul on resources1 and 2 ####' res = r.create_reservation([resource_id1, resource_id2], millis3, millis4, 'title', 'description') test_print(desc, res.status_code < 300) desc = '#### create reservation for rahul on resource3 ####' res = r.create_reservation([resource_id3], millis, millis2, 'title', 'description') test_print(desc, res.status_code < 300) desc = '#### create reservation for rahul on resources3 and 4 ####' res = r.create_reservation([resource_id3, resource_id4], millis3, millis4, 'title', 'description') test_print(desc, res.status_code < 300) r.session = ''
desc = '#### update resource with tags ####' res = r.update_resource(resource_id, "serverEdited", "huh edited") test_print(desc, res.status_code < 300) desc = '#### get updated resource ####' res = r.get_resource_by_id(resource_id) test_print(desc, res.status_code < 300) test_print(desc, r.json.loads(res.content)['results']['name'] == "serverEdited") millis = int(round(time.time() * 1000)) + 86400000 millis2 = int(round(time.time() * 1000)) + 2*86400000 millis3 = int(round(time.time() * 1000)) + 3*86400000 millis4 = int(round(time.time() * 1000)) + 4*86400000 desc = '#### create reservation ####' res = r.create_reservation([restricted_id, resource_id], millis, millis2, 'title', 'description') test_print(desc, res.status_code < 300) reservation_id = r.json.loads(res.content)['results']['insertId'] res = r.get_reservations([resource_id],0, 999999 ) desc = '#### create an aliasing reservation ####' res = r.create_reservation([resource_id], millis, millis2, 'title', 'description') test_print(desc, res.status_code >= 400) desc = '#### create a reservation with invalid start_time/end_time ####' res = r.create_reservation([resource_id], 3, 3, 'title', 'description') test_print(desc, res.status_code >= 400) desc = '#### create another valid reservation ####' res = r.create_reservation([resource_id, restricted_id], millis3, millis4, 'title', 'description') test_print(desc, res.status_code < 300)
test_print(desc, res.status_code > 300) r.session = '' desc = '#### login as rahul ####' session_response = r.login_to_session('rahul', 'rahul123') test_print(desc, session_response.status_code < 300) rahul_session = session_response.cookies r.session = rahul_session millis = int(round(time.time() * 1000)) + 86400000 millis2 = int(round(time.time() * 1000)) + 2*86400000 millis3 = int(round(time.time() * 1000)) + 3*86400000 millis4 = int(round(time.time() * 1000)) + 4*86400000 desc = '#### create reservation for rahul on resource1 ####' res = r.create_reservation([resource_id1], millis, millis2, 'title', 'description') test_print(desc, res.status_code < 300) desc = '#### create reservation for rahul on resource2 ####' res = r.create_reservation([resource_id2], millis, millis2, 'title', 'description') test_print(desc, res.status_code < 300) r.session = admin_session desc = '#### get all reservations on resources, make sure there are 2 rows ####' res = r.get_reservations_by_resources([resource_id1, resource_id2, resource_id3, resource_id4]) test_print(desc, len(r.json.loads(res.content)['results']) == 2) desc = '#### remove view permission from folder1 ####' res = r.remove_group_permission_to_resource(folder_id1, [group_id1]) test_print(desc, res.status_code < 300)
desc = '#### delete resource without tags ####' res = r.delete_resource(no_tags_id) test_print(desc, res.status_code < 300) desc = '#### update resource with tags ####' res = r.update_resource(resource_id, "serverEdited", "huh edited") test_print(desc, res.status_code < 300) desc = '#### get updated resource ####' res = r.get_resource_by_id(resource_id) test_print(desc, res.status_code < 300) test_print(desc, r.json.loads(res.content)['results']['name'] == "serverEdited") desc = '#### create reservation ####' res = r.create_reservation([resource_id], 1, 2, 'title', 'description') print r.json.loads(res.content) test_print(desc, res.status_code < 300) reservation_id = r.json.loads(res.content)['results']['insertId'] desc = '#### create an aliasing reservation ####' res = r.create_reservation([resource_id], 2, 3, 'title', 'description') test_print(desc, res.status_code >= 400) desc = '#### create a reservation with invalid start_time/end_time ####' res = r.create_reservation([resource_id], 3, 3, 'title', 'description') test_print(desc, res.status_code >= 400) desc = '#### create another valid reservation ####' res = r.create_reservation([resource_id], 3, 4, 'title', 'description') test_print(desc, res.status_code < 300)