def test_case_view(project, test_case_name): # check if user has permissions for this project if not user.has_permissions_to_project(g.user.id, project, root_path, 'gui'): return render_template('not_permission.html') # check if the file is locked # is_locked_by = lock.is_file_locked(root_path, project, test_case_name) # print(is_locked_by, g.user.username) # if is_locked_by and is_locked_by != g.user.username: # abort(404, 'This file is locked by someone else.') # else: tc_name, parents = utils.separate_file_from_parents(test_case_name) path = test_case.generate_test_case_path(root_path, project, test_case_name) error = utils.validate_python_file_syntax(path) if error: return render_template('test_builder/test_case_syntax_error.html', project=project, full_test_case_name=test_case_name) else: test_case_contents = test_case.get_test_case_content(root_path, project, test_case_name) test_data = test_data_module.get_test_data(root_path, project, test_case_name) return render_template('test_builder/test_case.html', project=project, test_case_contents=test_case_contents, test_case_name=tc_name, full_test_case_name=test_case_name, test_data=test_data)
def test_case_view(project, test_case_name): # check if user has permissions for this project if not user.has_permissions_to_project(g.user.id, project, root_path, 'gui'): return render_template('not_permission.html') # check if the file is locked # is_locked_by = lock.is_file_locked(root_path, project, test_case_name) # print(is_locked_by, g.user.username) # if is_locked_by and is_locked_by != g.user.username: # abort(404, 'This file is locked by someone else.') # else: tc_name, parents = utils.separate_file_from_parents(test_case_name) path = test_case.generate_test_case_path(root_path, project, test_case_name) error = utils.validate_python_file_syntax(path) if error: return render_template('test_builder/test_case_syntax_error.html', project=project, full_test_case_name=test_case_name) else: test_case_contents = test_case.get_test_case_content( root_path, project, test_case_name) test_data = test_data_module.get_test_data(root_path, project, test_case_name) return render_template('test_builder/test_case.html', project=project, test_case_contents=test_case_contents, test_case_name=tc_name, full_test_case_name=test_case_name, test_data=test_data)
def test_incorrect_syntax(self, filecontent, expected, dir_function): filename = 'test_python_syntax.py' filepath = os.path.join(dir_function['path'], filename) with open(filepath, 'w') as f: f.write(filecontent) error = utils.validate_python_file_syntax(filepath) assert expected in error
def save_page_object_code(): if request.method == 'POST': project = request.json['project'] page_object_name = request.json['pageObjectName'] content = request.json['content'] path = page_object.generate_page_path(root_path, project, page_object_name) page_object.save_page_object_code(root_path, project, page_object_name, content) error = utils.validate_python_file_syntax(path) return json.dumps({'error': error})
def save_page_object_code(): if request.method == 'POST': project = request.json['project'] page_object_name = request.json['pageObjectName'] content = request.json['content'] path = page_object.generate_page_path(root_path, project, page_object_name) page_object.save_page_object_code(root_path, project, page_object_name, content) error = utils.validate_python_file_syntax(path) return json.dumps({'error': error})
def test_syntax_correct(self, dir_function): filename = 'test_python_syntax.py' filepath = os.path.join(dir_function['path'], filename) filecontent = ('import os\n' 'var = 2 + 2\n' 'print(var)\n' 'def func():\n' ' pass\n') with open(filepath, 'w') as f: f.write(filecontent) error = utils.validate_python_file_syntax(filepath) assert error == ''
def page_code_view(project, full_page_name, no_sidebar=False): if not user.has_permissions_to_project(g.user.id, project, root_path, 'gui'): return render_template('not_permission.html') path = page_object.generate_page_path(root_path, project, full_page_name) error = utils.validate_python_file_syntax(path) page_object_code = page_object.get_page_object_code(path) return render_template('page_builder/page_object_code.html', project=project, page_object_code=page_object_code, page_name=full_page_name, error=error, no_sidebar=no_sidebar)
def page_code_view(project, full_page_name, no_sidebar=False): if not user.has_permissions_to_project(g.user.id, project, root_path, 'gui'): return render_template('not_permission.html') path = page_object.generate_page_path(root_path, project, full_page_name) error = utils.validate_python_file_syntax(path) page_object_code = page_object.get_page_object_code(path) return render_template('page_builder/page_object_code.html', project=project, page_object_code=page_object_code, page_name=full_page_name, error=error, no_sidebar=no_sidebar)
def save_test_case_code(): if request.method == 'POST': projectname = request.json['project'] test_case_name = request.json['testCaseName'] table_test_data = request.json['testData'] content = request.json['content'] # test_data.save_test_data(root_path, projectname, test_case_name, test_data) test_case.save_test_case_code(root_path, projectname, test_case_name, content, table_test_data) path = test_case.generate_test_case_path(root_path, projectname, test_case_name) error = utils.validate_python_file_syntax(path) return json.dumps({'error': error})
def save_test_case_code(): if request.method == 'POST': projectname = request.json['project'] test_case_name = request.json['testCaseName'] table_test_data = request.json['testData'] content = request.json['content'] # test_data.save_test_data(root_path, projectname, test_case_name, test_data) test_case.save_test_case_code(root_path, projectname, test_case_name, content, table_test_data) path = test_case.generate_test_case_path(root_path, projectname, test_case_name) error = utils.validate_python_file_syntax(path) return json.dumps({'error': error})
def app_view(project, full_page_name, no_sidebar=False): if not user.has_permissions_to_project(g.user.id, project, root_path, 'gui'): return render_template('not_permission.html') path = page_object.generate_page_path(root_path, project, full_page_name) error = utils.validate_python_file_syntax(path) if error: return render_template('app_builder/app_syntax_error.html', project=project, app_page_name=full_page_name) else: page_data = app_object.get_app_object_content(project, full_page_name) return render_template('app_builder/app_object.html', project=project, app_object_data=page_data, app_name=full_page_name, no_sidebar=no_sidebar)
def test_case_code_view(project, test_case_name): # check if user has permissions for this project if not user.has_permissions_to_project(g.user.id, project, root_path, 'gui'): return render_template('not_permission.html') tc_name, parents = utils.separate_file_from_parents(test_case_name) path = os.path.join(root_path, 'projects', project, 'tests', os.sep.join(parents), tc_name + '.py') test_case_contents = test_case.get_test_case_code(path) error = utils.validate_python_file_syntax(path) external_data = test_data_module.get_external_test_data(root_path, project, test_case_name) test_data_setting = test_execution.settings['test_data'] return render_template('test_builder/test_case_code.html', project=project, test_case_contents=test_case_contents, test_case_name=tc_name, full_test_case_name=test_case_name, test_data=external_data, test_data_setting=test_data_setting, error=error)
def test_case_code_view(project, test_case_name): # check if user has permissions for this project if not user.has_permissions_to_project(g.user.id, project, root_path, 'gui'): return render_template('not_permission.html') tc_name, parents = utils.separate_file_from_parents(test_case_name) path = os.path.join(root_path, 'projects', project, 'tests', os.sep.join(parents), tc_name + '.py') test_case_contents = test_case.get_test_case_code(path) error = utils.validate_python_file_syntax(path) external_data = test_data_module.get_external_test_data(root_path, project, test_case_name) test_data_setting = test_execution.settings['test_data'] return render_template('test_builder/test_case_code.html', project=project, test_case_contents=test_case_contents, test_case_name=tc_name, full_test_case_name=test_case_name, test_data=external_data, test_data_setting=test_data_setting, error=error)