def test_get_external_test_data_special_cases(self, project_function_clean, test_utils): testdir = project_function_clean['testdir'] project = project_function_clean['name'] test_name = test_utils.random_string(10, 'test') data_path = os.path.join(testdir, 'projects', project, 'tests', test_name + '.csv') input = ('key1\n' 'string with spaces\n' '"string ""with"" quotes"\n' 'string \'with\' quotes\n' '"""quoted_string"""\n' '\'quoted_string\'\n') with open(data_path, 'w+') as f: f.write(input) result = test_data.get_external_test_data(testdir, project, test_name) expected = [{ 'key1': 'string with spaces' }, { 'key1': 'string "with" quotes' }, { 'key1': 'string \'with\' quotes' }, { 'key1': '"quoted_string"' }, { 'key1': '\'quoted_string\'' }] assert result == expected
def test_get_external_test_data_file_not_exists(self, project_function_clean, test_utils): _, project = project_function_clean.activate() test_name = test_utils.random_string(10, 'test') result = test_data.get_external_test_data(project, test_name) assert result == []
def test_get_external_test_data_file_not_exists(self, project_function_clean, test_utils): testdir = project_function_clean['testdir'] project = project_function_clean['name'] test_name = test_utils.random_string(10, 'test') result = test_data.get_external_test_data(testdir, project, test_name) assert result == []
def test_case_code_view(project, test_name): test = Test(project, test_name) if not test.exists: abort(404, 'The test {} does not exist'.format(test_name)) _, error = utils.import_module(test.path) external_data = test_data_module.get_external_test_data(project, test_name) test_data_setting = session.settings['test_data'] return render_template('test_builder/test_case_code.html', project=project, test_case_contents=test.code, test_case_name=test.stem_name, full_test_case_name=test_name, test_data=external_data, test_data_setting=test_data_setting, error=error)
def test_case_code_view(project, test_case_name): test_exists = test_case.test_case_exists(project, test_case_name) if not test_exists: abort(404, 'The test {} does not exist'.format(test_case_name)) tc_name, parents = utils.separate_file_from_parents(test_case_name) path = os.path.join(session.testdir, 'projects', project, 'tests', os.sep.join(parents), tc_name + '.py') test_case_contents = test_case.get_test_case_code(path) _, error = utils.import_module(path) external_data = test_data_module.get_external_test_data(project, test_case_name) test_data_setting = session.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_get_external_test_data(self, project_function_clean, test_utils): _, project = project_function_clean.activate() test_name = test_utils.random_string(10, 'test') data_path = os.path.join(project_function_clean.path, 'tests', test_name + '.csv') input = ('key1,key2\nvalue1,value2\nvalue3,value4\n') with open(data_path, 'w+') as f: f.write(input) result = test_data.get_external_test_data(project, test_name) expected = [{ 'key1': 'value1', 'key2': 'value2' }, { 'key1': 'value3', 'key2': 'value4' }] assert result == expected
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.import_module(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)
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) test_case_contents = test_case.get_test_case_content( root_path, project, test_case_name) 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_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)