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") is_failure(desc, res) """" ---login as non_admin--- """ r.session = non_admin_session desc = '### confirm restricted1 w/ no permissions ###' res = r.confirm_resource_reservation(restricted_id2, r2r1_id) is_failure(desc, res) desc = '### deny restricted resource w/ no permission ###' res = r.deny_resource_reservation(restricted_id1, r2r1_id) is_failure(desc, res) desc = "### test that resource cannot be updated w/ no permissions ###" res = r.update_resource(restricted_id1, "s", "s", "free") is_failure(desc, res) """ ---login as admin--- """ r.session = admin_session desc = '### confirm restricted1 on reservation w/ two restricted resources ###' res = r.confirm_resource_reservation(restricted_id2, r2r1_id) is_success(desc, res) desc = '### make sure overlapping reservation was not deleted yet ###' res = r.get_reservations_by_resources([restricted_id1]) is_success(desc, res)
desc = "### get all reservations for resource_id and no_tags_id" res = r.get_reservations_by_resources([resource_id, no_tags_id]) test_print (desc, len(r.json.loads(res.content)['results']) == 3) test_print(desc, res.status_code < 300) desc = '#### delete resource without tags, reservation should also be deleted ####' res = r.delete_resource(no_tags_id) test_print(desc, res.status_code < 300) desc = "### get all reservations for resource_id and no_tags_id and make sure the no_tags reservation is gone" res = r.get_reservations_by_resources([resource_id, no_tags_id]) test_print (desc, len(r.json.loads(res.content)['results']) == 2) test_print(desc, res.status_code < 300) desc = "### deny request for resource ###" res = r.deny_resource_reservation(restricted_id, reservation_id) test_print(desc, res.status_code < 300) desc = "### confirm request for resource ###" res = r.confirm_resource_reservation(restricted_id, reservation_id2) test_print(desc, res.status_code < 300) r.session = '' desc = '#### create non-admin session ####' session_response = r.login_to_session('rahul', 'rahul123') test_print(desc, session_response.status_code < 300) rahul_session = session_response.cookies desc = "### fail to remove resource from someone else's reservation ###" r.session = rahul_session res = r.remove_resource_from_reservation(reservation_id, [resource_id])