def create_folder(user=None, project=None, targetfolder=None, name=None, **kwargs): project, user = statics.set_project_user(project=project, user=user) if name is None: raise ValueError( "user, project, and name must be specified. {locals}".format( locals=str(locals()))) new_folder = _create_new_folder(user=user, project=project, parent=targetfolder, **kwargs) folder_id = new_folder["data"]["id"] new_folder = _rename_folder(user=user, project=project, parent=targetfolder, folder_id=folder_id, name=name, **kwargs) return folder_id
def _rename_script(user=None, project=None, new_name=None, script_id=None, **kwargs): project, user = statics.set_project_user(project=project, user=user) if user is None or project is None or new_name is None or script_id is None: raise ValueError( "script_id, user, project and name must be specified. {locals}". format(locals=str(locals()))) headers = authentication.testpad_headers( user=user, referer="{url}/project/{project}/".format(url=user.testpad_url, project=project)) data = {"data": new_name} rename_response = requests.post( "{url}/a/script/{script_id}/editname".format(url=user.testpad_url, script_id=script_id), headers=headers, json=data) assert rename_response.status_code is 200 authentication.update_cookies(response=rename_response, user=user, **kwargs) return rename_response.json()
def report_with_steps(user=None, project=None, report_folder=None, name=None, auth_token=None, **kwargs): project, user = statics.set_project_user(project=project, user=user) if user is None and auth_token is None: raise ValueError( "user or auth_token must be specified. {locals}".format( locals=str(locals()))) if project is None or report_folder is None: raise ValueError( "project and targetfolder must be specified. {locals}".format( locals=str(locals()))) # https://recordsure.ontestpad.com/project/11/folder/f277/report/S headers = authentication.testpad_headers( user=user, referer="{url}/project/{project}/".format(url=user.testpad_url, project=project)) response = requests.get( '{url}/project/{project}/folder/{folder}/report/Sb'.format( url=user.testpad_url, project=project, folder=report_folder), headers=headers) assert response.status_code is 200 return response.content
def load_scripts(user=None, project=None, targetfolder=None, **kwargs): project, user = statics.set_project_user(project=project, user=user) headers = authentication.testpad_headers( user=user, referer="{url}/project/{project}/folder/{folder}".format( url=user.testpad_url, project=project, folder=targetfolder)) load_scripts_response = requests.post( '{url}/a/project/{project}/folder/{folder}/loadScripts'.format( url=user.testpad_url, project=project, folder=targetfolder), headers=headers, json='{"data":null}') authentication.update_cookies(response=load_scripts_response, user=user, **kwargs) return load_scripts_response.json()
def create_script(user=None, project=None, targetfolder=None, name=None, **kwargs): project, user = statics.set_project_user(project=project, user=user) if user is None or project is None or targetfolder is None or name is None: raise ValueError( "user, project, targetfolder and name must be specified. {locals}". format(locals=str(locals()))) new_script = _create_new_script(user=user, project=project, folder=targetfolder, **kwargs) rename_script = _rename_script(user=user, project=project, new_name=name, script_id=new_script['data']['id']) assert rename_script['status'] == "OK" return new_script
def populate_script(user=None, project=None, script_id=None, text=None, **kwargs): project, user = statics.set_project_user(project=project, user=user) if user is None or project is None or script_id is None or text is None: raise ValueError( "script_id, user and project must be specified. {locals}".format( locals=str(locals()))) headers = authentication.testpad_headers( user=user, referer=("{url}/script/{script_id}/".format(url=user.testpad_url, script_id=script_id))) data = {"data": ScriptBuilder(text=text).build()} response = requests.post("{url}/a/script/{script_id}/insertMany".format( url=user.testpad_url, script_id=script_id), headers=headers, json=data) assert response.status_code is 200 return response.json()