def test_get_test_case_code(self, project_class): test_name = 'some_test_case2' path = os.path.join(project_class.path, 'tests', test_name + '.py') with open(path, 'w') as f: f.write(SAMPLE_TEST_CONTENT) test_code = test_case.get_test_case_code(path) assert test_code == SAMPLE_TEST_CONTENT
def test_get_test_case_code(self, random_project_fixture): test_name = 'some_test_case2' root_path = random_project_fixture['testdir'] project = random_project_fixture['name'] path = os.path.join(root_path, 'projects', project, 'tests', test_name + '.py') with open(path, 'w') as ff: ff.write(SAMPLE_TEST_CONTENT) test_code = test_case.get_test_case_code(path) assert test_code == SAMPLE_TEST_CONTENT
def test_new_test_case(self, project_class): testdir = project_class.testdir project = project_class.name test_name = 'new_test_case_001' parents = ['aaaa', 'bbbb'] errors = test_case.new_test_case(testdir, project, parents, test_name) path = os.path.join(project_class.path, 'tests', os.sep.join(parents), test_name+'.py') assert os.path.isfile(path) assert errors == [] test_code = test_case.get_test_case_code(path) assert test_code == NEW_TEST_CONTENT
def test_new_test_case(self, project_fixture): root_path = project_fixture['testdir'] project = project_fixture['name'] test_name = 'new_test_case_001' parents = ['aaaa', 'bbbb'] errors = test_case.new_test_case(root_path, project, parents, test_name) path = os.path.join(root_path, 'projects', project, 'tests', os.sep.join(parents), test_name + '.py') assert os.path.isfile(path) assert errors == [] test_code = test_case.get_test_case_code(path) assert test_code == NEW_TEST_CONTENT
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_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)