def create_test(project, name, content=None): if content is None: content = ('def test(data):\n' ' print("hello")\n') test.create_test(project, name) test.edit_test_code(project, name, content, table_test_data=[]) return test.Test(project, name).path
def test_code_save(): project = request.json['project'] test_name = request.json['testName'] table_test_data = request.json['testData'] content = request.json['content'] _verify_permissions(Permissions.STANDARD, project) test_module.edit_test_code(project, test_name, content, table_test_data) path = test_module.Test(project, test_name).path _, error = utils.import_module(path) return jsonify({'error': error})
def run_test(code, test_data={}, secrets={}, from_suite=False): test_module.edit_test_code(project, test_name, code, []) test_runner.run_test(testdir, project, test_name, test_data, secrets, browser, settings, report_directory, from_suite=from_suite)
def test_edit_test_code_csv_data(self, project_session, test_utils): _, project = project_session.activate() test_data = [{'key': "'value'"}] settings_manager.save_project_settings(project, '{"test_data": "csv"}') test_name = test_utils.create_random_test(project) test_module.edit_test_code(project, test_name, SAMPLE_TEST_CONTENT, test_data) path = test_module.Test(project, test_name).path with open(path) as f: assert f.read() == SAMPLE_TEST_CONTENT path = os.path.join(Project(project).test_directory_path, test_name + '.csv') expected = ('key\n' '\'value\'\n') with open(path) as f: assert f.read() == expected
def test_code_save(): project = request.json['project'] test_name = request.json['testName'] test_data = request.json['testData'] content = request.json['content'] _verify_permissions(Permissions.STANDARD, project) test_error = None data_errors = [] if test_data['json']: data_errors.extend(utils.json_parse_error(test_data['json'])) if not data_errors: test_module.edit_test_code(project, test_name, content, test_data) path = test_module.Test(project, test_name).path _, test_error = utils.import_module(path) return jsonify({'testError': test_error, 'dataErrors': data_errors})
def set_content(test_content): test_module.edit_test_code(project, test_name, test_content)