text
stringlengths
692
2.15k
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /config/rest/delete/ ###Description: requesting to delete the config values when provided valid config name but with invalid token ###Inputs: config_value = { "name": "primary_server" } ###Output: { "status": 401, "message": "Invalid token" } ###Answer: def test_config_delete_with_invalid_token(invalid_exec_api): """ deleting the non deletable config values with invalid token """ config_value = { "name": "primary_server", } r = invalid_exec_api.config_delete(config_value) test_assert.status(r, 401) result = r.json() assert result['detail'] == "Invalid token." </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /config/rest/version/ ###Description: Fetching the information when invalid token is provided ###Inputs: None ###Output: { "status":401, "message":"invalid token" } ###Answer: def test_version_config_with_invalid_token(invalid_exec_api): """ Fetching the information of Version and Build Number with invalid token """ r = invalid_exec_api.config_version() result = r.json() test_assert.status(r, 401) assert result['detail'] == "Invalid token." </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /deploy/rest/delete/{UUID}/ ###Description: the manager deletes the image when the manager has rights over the user and the server ###Inputs: None ###Output: { "status":204 } ###Answer: endpoint = "deploy_delete" PARAMETERS = [{"dest_obj": OBJ_DEPL}] PARAMETERS_SRV_RIGHT = [{"dest_obj": OBJ_DEPL, "deploy_with": SRV_MANAGER_RIGHTS}] PARAMETERS_NO_SRV_RIGHT = [{"dest_obj": OBJ_DEPL, "deploy_with": SRV_NO_MANAGER_RIGHTS}] @pytest.mark.parametrize("custom_lib_non_admin_operations", PARAMETERS_SRV_RIGHT, indirect=True) @pytest.mark.parametrize("custom_lib_admin_operations", PARAMETERS_SRV_RIGHT, indirect=True) def test_deploy_delete_manager_server_right(skip_if_not_manager, custom_lib_admin_operations, custom_lib_non_admin_operations, run_api): """ Deleting the VM by Manager """ # When the user is not part of the group that the manager manages and deployment is on manager rights to server deploy_id = custom_lib_admin_operations r = run_api.deploy_image_delete(deploy_id, {}) test_assert.status(r, manager_rights_response(endpoint, manages_user=False, manages_server=True)) # When the user is part of the group that the manager manages and deployment is on manager rights to server deploy_id = custom_lib_non_admin_operations r = run_api.deploy_image_delete(deploy_id, {}) test_assert.status(r, manager_rights_response(endpoint, manages_user=True, manages_server=True)) </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /deploy/rest/shutdown/{{UUID}}/ ###Description: shutting down the deployment of machine by an admin using valid UUID and machine is in running state ###Inputs: None ###Output: { "status" : 201, "response" : Machine shutdown } ###Answer: PARAMETERS = [{"dest_obj": OBJ_DEPL, "final_state": DEPL_STATE["running"]}] @pytest.mark.parametrize("custom_lib_non_admin_operations", PARAMETERS, indirect=True) def test_deploy_shutdown_admin(skip_if_not_admin, custom_lib_non_admin_operations, run_api): """ shutdown the VM by Admin """ deploy_id = custom_lib_non_admin_operations r = run_api.deploy_shutdown(deploy_id) test_assert.status(r, 201) </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /deploy/rest/stop/{{UUID}}/ ###Description: stopping a machine by an admin when valid UUID is provided and machine is in running state ###Inputs: None ###Output: { "status" : 201, "response" : stopping deployment } ###Answer: endpoint = "deploy_stop" PARAMETERS = [{"dest_obj": OBJ_DEPL, "final_state": DEPL_STATE["running"]}] PARAMETERS_SRV_RIGHT = [{"dest_obj": OBJ_DEPL, "final_state": DEPL_STATE["running"], "deploy_with": SRV_MANAGER_RIGHTS}] PARAMETERS_NO_SRV_RIGHT = [{"dest_obj": OBJ_DEPL, "final_state": DEPL_STATE["running"], "deploy_with": SRV_NO_MANAGER_RIGHTS}] @pytest.mark.parametrize("custom_lib_non_admin_operations", PARAMETERS, indirect=True) def test_deploy_stop_admin(skip_if_not_admin, custom_lib_non_admin_operations, run_api): """ Rebooting the VM by Admin """ # Admin check of Starting a deployment created by different user deploy_id = custom_lib_non_admin_operations r = run_api.deploy_stop(deploy_id) test_assert.status(r, 201) </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /deploy/rest/stop/{{UUID}}/ ###Description: stopping a machine by non-admin user when valid UUID is provided and machine is in running state ###Inputs: None ###Output: { "status" : 403 } ###Answer: endpoint = "deploy_stop" PARAMETERS = [{"dest_obj": OBJ_DEPL, "final_state": DEPL_STATE["running"]}] PARAMETERS_SRV_RIGHT = [{"dest_obj": OBJ_DEPL, "final_state": DEPL_STATE["running"], "deploy_with": SRV_MANAGER_RIGHTS}] PARAMETERS_NO_SRV_RIGHT = [{"dest_obj": OBJ_DEPL, "final_state": DEPL_STATE["running"], "deploy_with": SRV_NO_MANAGER_RIGHTS}] @pytest.mark.parametrize("custom_lib_admin_operations", PARAMETERS, indirect=True) def test_deploy_stop_non_admin(skip_if_not_non_admin, custom_lib_admin_operations, run_api): """ stopping the VM by non-admin """ deploy_id = custom_lib_admin_operations r = run_api.deploy_stop(deploy_id) test_assert.status(r, 403) </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /deploy/rest/stop/{{UUID}}/ ###Description: stopping a machine deployment by a manager when valid UUID is provided and machine is in running state , and manager has rights over servers ###Inputs: None ###Output: None ###Answer: endpoint = "deploy_stop" PARAMETERS = [{"dest_obj": OBJ_DEPL, "final_state": DEPL_STATE["running"]}] PARAMETERS_SRV_RIGHT = [{"dest_obj": OBJ_DEPL, "final_state": DEPL_STATE["running"], "deploy_with": SRV_MANAGER_RIGHTS}] PARAMETERS_NO_SRV_RIGHT = [{"dest_obj": OBJ_DEPL, "final_state": DEPL_STATE["running"], "deploy_with": SRV_NO_MANAGER_RIGHTS}] @pytest.mark.parametrize("custom_lib_non_admin_operations", PARAMETERS_SRV_RIGHT, indirect=True) @pytest.mark.parametrize("custom_lib_admin_operations", PARAMETERS_SRV_RIGHT, indirect=True) def test_deploy_stop_manager_server_right(skip_if_not_manager, custom_lib_admin_operations, custom_lib_non_admin_operations, run_api): """ stopping the VM by manager when have right on server """ # When the user is not part of the group that the manager manages deploy_id = custom_lib_admin_operations r = run_api.deploy_stop(deploy_id) test_assert.status(r, manager_rights_response(endpoint, manages_user=False, manages_server=True)) # When the user is part of the group that the manager manages and deployment is on manager rights to server deploy_id = custom_lib_non_admin_operations r = run_api.deploy_stop(deploy_id) test_assert.status(r, manager_rights_response(endpoint, manages_user=True, manages_server=True)) run_api.deploy_stop(deploy_id) </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /deploy/rest/stop/{{UUID}}/ ###Description: stopping a machine deployment by a manager when valid UUID is provided and machine is in running state , but manager do not have rights over servers ###Inputs: None ###Output: None ###Answer: endpoint = "deploy_stop" PARAMETERS = [{"dest_obj": OBJ_DEPL, "final_state": DEPL_STATE["running"]}] PARAMETERS_SRV_RIGHT = [{"dest_obj": OBJ_DEPL, "final_state": DEPL_STATE["running"], "deploy_with": SRV_MANAGER_RIGHTS}] PARAMETERS_NO_SRV_RIGHT = [{"dest_obj": OBJ_DEPL, "final_state": DEPL_STATE["running"], "deploy_with": SRV_NO_MANAGER_RIGHTS}] @pytest.mark.parametrize("custom_lib_non_admin_operations", PARAMETERS_NO_SRV_RIGHT, indirect=True) @pytest.mark.parametrize("custom_lib_admin_operations", PARAMETERS_NO_SRV_RIGHT, indirect=True) def test_deploy_stop_manager_no_server_right(skip_if_not_manager, custom_lib_admin_operations, custom_lib_non_admin_operations, run_api): """ stopping the VM by manager when have no right on server """ # When the user is not part of the group that the manager manages and the deployment is not on manager rightful server deploy_id = custom_lib_admin_operations r = run_api.deploy_stop(deploy_id) test_assert.status(r, manager_rights_response(endpoint, manages_user=False, manages_server=False)) # When the user is part of the group that the manager manages but the deployment is not on manager rightful server deploy_id = custom_lib_non_admin_operations r = run_api.deploy_stop(deploy_id) test_assert.status(r, manager_rights_response(endpoint, manages_user=True, manages_server=False)) </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /ilibrary/rest/add/ ###Description: creating an island library and adding it using invalid IPs ###Inputs: { "name": "test_ilibrary_add_invalid_ips", "is_public": True, "network_segments": { "add": [ { "name": "network_segment", "bridge_ip": "1921681000", "start_ip": "1921681001", "end_ip": "192168100150" } ] } } ###Output: { "status" : 400, "message" : "Enter valid IPv4 addresses" } ###Answer: def test_ilibrary_add_invalid_ips(run_api): """ Creating an Island Library with invalid bridge ip, start ip, end ip """ params = { "name": "test_ilibrary_add_invalid_ips", "is_public": True, "network_segments": { "add": [ { "name": "network_segment", "bridge_ip": "1921681000", "start_ip": "1921681001", "end_ip": "192168100150" } ] } } params, r = run_api.ilibrary_add_new_island(params=params) test_assert.status(r, 400) rjson = r.json() errors = rjson['network_segments']['add'][0] assert errors['start_ip'] == ['Enter a valid IPv4 address.'] assert errors['end_ip'] == ['Enter a valid IPv4 address.'] assert errors['bridge_ip'] == ['Enter a valid IPv4 address.'] </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /ilibrary/rest/details/{UUID}/ ###Description: fetching details of public island library from private island ###Inputs: machine1 = { "uuid": r1.json()["uuid"], "nics": { "add": [ { "mac": "auto", "type": "bridge", "model": networks[0].get("model", "virtio"), "segment": "Default Public Segment" }, ], } } params = { "name": "Machine1", "is_public": False, "machines": { "add": [machine1], }, } ###Output: { "response" : success } ###Answer: def test_ilibrary_details_with_edit_private_island_to_public_island(skip_if_not_admin, run_api): """ To check machine type with public island """ params1, r1 = run_api.library_add_new_vm(networks=networks) machine1 = { "uuid": r1.json()["uuid"], "nics": { "add": [ { "mac": "auto", "type": "bridge", "model": networks[0].get("model", "virtio"), "segment": "Default Public Segment" }, ], } } params = { "name": "Machine1", "is_public": False, "machines": { "add": [machine1], }, } params, r = run_api.ilibrary_add_new_island(params=params) island_id = r.json()["uuid"] params, r = run_api.ilibrary_edit_island(uuid=island_id, params={"is_public": True}) res = r.json()["machines"] run_api.ilibrary_delete(uuid=island_id) run_api.library_delete(r1.json()["uuid"]) for machine in res: if not machine["is_public"]: assert False, "The json is %s" % r.json() </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /library/rest/add ###Description: adding vm to library when multiple boot disks and same order is passed ###Inputs: disks = [{ "size": 20, "port": "sdb", "type": "sata", "format": "qcow2", "is_boot": True, "boot_order": 1 }, { "size": 20, "port": "sda", "type": "sata", "format": "qcow2", "is_boot": True, "boot_order": 1 }] ###Output: { "status" : 400, "response" : Bad request } ###Answer: def test_add_vm_to_library_multiple_bootable_disk_with_same_boot_order(run_api): """ If multiple bootable cds with same boot order is passed """ disks = [{ "size": 20, "port": "sdb", "type": "sata", "format": "qcow2", "is_boot": True, "boot_order": 1 }, { "size": 20, "port": "sda", "type": "sata", "format": "qcow2", "is_boot": True, "boot_order": 1 }] params, response = run_api.library_add_new_vm(disks=disks, noraise=True) test_assert.status(response, 400) </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /library/rest/adddisk/{{UUID}}/ ###Description: adding disk to library when provided lib_UUID that does not exist ###Inputs: lib_UUID = "doesnotexist" ###Output: { "status" : 404 } ###Answer: def test_lib_add_disk_with_invalid_UUID(run_api): lib_UUID = "doesnotexist" r = run_api.library_add_disk(lib_UUID) test_assert.status(r, 404) </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /library/rest/ctypes/ ###Description: getting the console type when requested ###Inputs: None ###Output: { "status" : 200, "response" : console type details displayed } ###Answer: def test_library_ctypes(run_api): """ Getting the list of console type """ r = run_api.library_console_types() result = r.json() test_assert.status(result, LIBRARY_CONSOLE_TYPE, "library_ctypes") test_assert.status(r, 200) </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /library/rest/delete/{UUID}/ ###Description: deleting a library by non-admin when provided with valid UUID ###Inputs: None ###Output: { "status" : 403 } ###Answer: PARAMETERS = [{"dest_obj": OBJ_LIB}] @pytest.mark.parametrize("custom_lib_admin_operations", PARAMETERS, indirect=True) def test_lib_delete_non_admin(skip_if_not_non_admin, custom_lib_admin_operations, run_api): """ Deleting the Library by non-Admin """ # Non-admin check for deleting the Library created by different user. lib_id = custom_lib_admin_operations r = run_api.library_delete(lib_id, {}) test_assert.status(r, 403) </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /library/rest/edit/{UUID}/ ###Description: deletion of disk when invalid UUID provided ###Inputs: {"delete": [ { "UUID": disk_UUID, "port": "sdz", "type": r['hw']['disks'][0]['type'] } ] } ###Output: { "status" : 404, "message" : "Disk with UUID does not exist" } ###Answer: def test_library_edit_delete_invalid_disk_UUID(library_add_new_vm, run_api): """ delete disk with invalid UUID """ p, r = library_add_new_vm lib_id = r['UUID'] disk_UUID = str(UUID.UUID4()) disk_UUID = 'invalid' disks = {"delete": [ { "UUID": disk_UUID, "port": "sdz", "type": r['hw']['disks'][0]['type'] } ] } params = {"hw": {"disks": disks}} res = run_api.library_edit(lib_id, params) test_assert.status(res, 404) rjson = res.json() assert rjson['error'] == f"Disk with UUID {disk_UUID} does not exist", "|> json %s" % rjson </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /library/rest/edit/{UUID}/ ###Description: updation of library when is_public flag set to True ###Inputs: params = { "is_public": True, "hw": {} } ###Output: { "status" : 400, "message" : "Failed to create task to sync public layers on primary" } ###Answer: def test_library_edit_update_is_public_flag(skip_if_not_non_admin, library_add_new_vm, run_api): """ Update is_public flag """ p, res = library_add_new_vm UUID = res['UUID'] params = { "is_public": True, "hw": {} } r = run_api.library_edit(UUID, params) test_assert.status(r, 400) rjson = r.json() assert rjson['error'] == "Failed to create task to sync public layers on primary", "Json |> %s" % rjson </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /library/rest/edit/{UUID}/ ###Description: updation of network in a library with valid data ###Inputs: networks = [{ "type": "bridge", "model": "virtio", "segment": "Default Public Segment", } ] update_network = [{ "type": "host", "model": "virtio", "segment": "HostOnly Segment", }] ###Output: { "status" : 201 } ###Answer: def test_library_edit_network_with_valid_data(run_api): """ edit network with valid data """ networks = [{ "type": "bridge", "model": "virtio", "segment": "Default Public Segment", } ] params, r = run_api.library_add_new_vm(networks=networks) update_netork = [{ "type": "host", "model": "virtio", "segment": "HostOnly Segment", }] params = {'hw': {'networks': update_netork}} lib_id = r.json()["UUID"] res = run_api.library_edit(lib_id, params) test_assert.status(res, 201) rjson = res.json() new_network = rjson['hw']['networks'][0] assert new_network['type'] == 'host', "|> Error %s" % rjson assert new_network['segment'] == 'HostOnly Segment', "|> Error %s" % rjson run_api.library_delete(lib_id, {}) </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: ​/library​/rest​/hvmtypes​/ ###Description: fetching the hypervisor type when requested ###Inputs: None ###Output: { "status" : 200, "response" : list of hypervisor type } ###Answer: def test_library_hvmtypes(run_api): """ Getting the list of Hypervisor type """ r = run_api.library_hvmtypes() result = r.json() test_assert.status(result, LIBRARY_HVM_TYPE, "library_hvmtypes") test_assert.status(r, 200) </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /library/rest/revisions/ ###Description: requesting the revision list of library when machine_UUID is empty ###Inputs: { machine_UUID : '' } ###Output: { "status" : 400, "message" : "Machine UUID should be provided"} ###Answer: def test_library_revisions_without_UUID(run_api): """ Without UUID """ res = run_api.library_revisions("") test_assert.status(res, 400) rjson = res.json() assert rjson['detail'] == "Machine UUID should be provided", "|> The error %s" % rjson </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: ​/rtask​/rest​/rlist​/ ###Description: fetching the list of remote tasks without authorization ###Inputs: None ###Output: { "status" : 401, "message" : "Authentication credentials were not provided" } ###Answer: def test_rtask_rlist_without_authorization(anonymous_exec_api): """ Fetching the List of Jobs without authorization """ r = anonymous_exec_api.rtask_rlist() res = r.json() test_assert.status(r, 401) assert res['detail'] == "Authentication credentials were not provided." </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: ideploy/rest/change_ownership ###Description: Successful change of ownership from one user to another where both users exist and the requester has the necessary permissions. ###Inputs: { "deployment_UUIDs": [UUID], "owner": , "dest_user": "manager" } ###Output: {"status": 200, "message": "Operation performed successfully without any error"} ###Answer: def test_deploy_change_ownership(skip_if_non_admin, non_admin_exec_api, run_api): """ To change ownership of deployed machine from non-admin user to manager by admin """ params, r = non_admin_exec_api.library_add_new_vm() lib_id = r.json()["UUID"] r = non_admin_exec_api.deploy_image(lib_id=lib_id, deploy_on=list(run_api.clm_my_servers.keys())) UUID = r.json()['UUID'] params = { "deployment_UUIDs": [UUID], "owner": non_admin_exec_api.user, "dest_user": "manager" } res = run_api.deploy_change_ownership(params=params) test_assert.status(res, 200) new_owner = run_api.deploy_details(deploy_id=UUID).json()['owner'] assert new_owner == "manager" run_api.deploy_image_delete(deploy_id=UUID) run_api.library_delete(UUID=lib_id) </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: license/rest/licenses_check ###Description: when day params is negative ###Inputs: { "days" : -1 } ###Output: { "status:200, "message": "Value of `days` cannot be negative" } ###Answer: def test_license_check_when_day_is_negative(run_api): """ license check when day is negative """ r = run_api.license_check(days=-1) rjson = r.json() test_assert.status(r, 400) assert rjson['error'] == "Value of `days` cannot be negative", "The error %s" % rjson </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /deploy/rest/deploylist ###Description: getting list of image of deployed machine by setting scope to "my". Check the user type before performing the operation, only admin user type have the permission to perform such operations. ###Inputs: { scope : "my" } ###Output: { "response" : success } ###Answer: def test_deploy_list_filter_with_scope_my(run_api, admin_exec_api, library_add_new_vm): """ filter deploy list using scope = my """ params, r = library_add_new_vm lib_id = r["uuid"] r = admin_exec_api.deploy_image(lib_id) deploy_id = r.json()["uuid"] count = check_count_deploylist(run_api, deploy_id, params={'scope': 'my', 'uuid': deploy_id}) if run_api.user_type == USER_TYPE['non_admin'] or run_api.user_type == USER_TYPE['manager']: assert count == 0 elif run_api.user_type == USER_TYPE['admin']: assert count == 1 r = admin_exec_api.deploy_image_delete(deploy_id) </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /config/rest/set/ ###Description: setting the None value to secret config. Check the user type before performing the operation, only admin user type have the permission to perform such operations. ###Inputs: { "name": "secret", "value": None } ###Output: { "status" : 400, "response" : 'Invalid secret_key Value' } ###Answer: def test_config_None_set_secret(run_api): """ Set the secret-key config value as None """ config_value = { "name": "secret", "value": None } r = run_api.config_set(config_value) res = r.json() if run_api.user_type in [USER_TYPE["manager"], USER_TYPE["non_admin"]]: test_assert.status(r, 403) elif run_api.user_type == USER_TYPE['admin']: test_assert.status(r, 400) assert res["result"] == 'FAILURE' assert 'Invalid secret_key Value' in res["error"], res </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /group/rest/add/ ###Description: adding new group when group name field is missing. Check the user type before performing the operation, only admin user type have the permission to perform such operations. ###Inputs: None ###Output: { "status" : 400, "message" : "Group Name is required and it can not be blank" } ###Answer: def test_add_group_with_group_name_field_missing(run_api): """ Adding new Group with group name field missing """ params, r = run_api.group_add(template={}) if run_api.user_type in [USER_TYPE["non_admin"], USER_TYPE["manager"]]: test_assert.status(r, 403) elif run_api.user_type == USER_TYPE["admin"]: result = r.json() test_assert.status(r, 400) assert result['error'] == "Group Name is required and it can not be blank" </s>
<s>[INST] ###System Write down a python function that tests the API scenario described below. Make sure you use appropriate docstring while writing code. Below are the endpoint, inputs and output of the function as well. Also check for the user type when needed. Keep in mind decorators and parameters. [/INST] ###Endpoint: /group/rest/update/ ###Description: updating the deployment strategy of a group using an invalid value. Check the user type before performing the operation, only admin user type have the permission to perform such operations. ###Inputs: { "name", "deployment_strategy": 'invalid' } ###Output: { "status" : 400, "message" : "Invalid deployment_strategy" } ###Answer: def test_group_update_invalid_deployment_strategy(skip_if_not_admin, group_add, run_api): """ group update invalid deployment_strategy """ params, r = group_add rjson = r.json() group_id = rjson['id'] group_param = { "name": rjson['name'], "deployment_strategy": 'invalid' } updated_param, r = run_api.group_update(group_id, group_param) run_api.user_type == USER_TYPE["admin"] result = r.json() test_assert.status(r, 400) assert result['error'] == "Invalid deployment_strategy", "|> Json %s" % result </s>
README.md exists but content is empty. Use the Edit dataset card button to edit it.
Downloads last month
0
Edit dataset card