Example #1
0
def save_test_case_code():
    if request.method == 'POST':
        project = request.json['project']
        test_case_name = request.json['testCaseName']
        table_test_data = request.json['testData']
        content = request.json['content']
        test_case.save_test_case_code(root_path, project, test_case_name,
                                      content, table_test_data)
        path = test_case.generate_test_case_path(root_path, project, test_case_name)
        _, error = utils.import_module(path)
        return json.dumps({'error': error})
Example #2
0
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)

        return json.dumps('ok')
Example #3
0
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})
Example #4
0
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})
Example #5
0
 def test_save_test_case_code_csv_data(self, project_function):
     _, project = project_function.activate()
     test_name = 'test_one'
     test_data = [{'key': "'value'"}]
     session.settings['test_data'] = 'csv'
     test_case.new_test_case(project, [], test_name)
     test_case.save_test_case_code(project, test_name, SAMPLE_TEST_CONTENT,
                                   test_data)
     path = os.path.join(project_function.path, 'tests', test_name + '.py')
     with open(path) as f:
         assert f.read() == SAMPLE_TEST_CONTENT
     path = os.path.join(project_function.path, 'tests', test_name + '.csv')
     expected = ('key\n' '\'value\'\n')
     with open(path) as f:
         assert f.read() == expected