Esempio n. 1
0
def init_data_service_config(request):
    query_data = {}
    result = devops_api.get_module(query_data)
    data_list = result.get('data')
    i =1
    for data in data_list:
        servcie_name = data.get('mod_name')
        kwargs = {
            'id': None,
            'service_name': servcie_name,
            'remark': data.get('bus_name') + '->' + data.get('prj_name') + '->' + data.get('prj_tag'),
            'creator': 'system'
        }

        servcie = ServiceConfig.objects.create(**kwargs)
        add_detail = {
            'service_config_id': servcie.id,
            'relation_id': servcie_name,
            'relation_name': servcie_name,
            'relation_type': 5,
            'creator': 'system',
        }
        ServiceConfigDetail.objects.create(**add_detail)
        i =i+1
        print(i)

    result = {'code': '1'}
    return JsonResponse(result)
Esempio n. 2
0
def edit_case(request, id=None):
    """
    编辑用例
    :param request:
    :param id:
    :return:
    """

    account = request.session["now_account"]
    user_type = request.session['user_type']
    if request.is_ajax():
        testcase_lists = json.loads(request.body.decode('utf-8'))
        tastcase = testcase_lists.get('test').get('name')
        author = tastcase.get('author')
        project = tastcase.get('project')
        module = tastcase.get('module')
        if not validate_operate(account, author, user_type, project, module):
            return HttpResponse(get_ajax_msg("非创建人或负责人不能修改,请检查", '/api/test_list/1/'))

        msg = case_info_logic(type=False, **testcase_lists)
        return HttpResponse(get_ajax_msg(msg, '/api/test_list/1/'))

    test_info = TestCaseInfo.objects.get_case_by_id(id)
    request = eval(test_info[0].request)
    include = eval(test_info[0].include)

    project = test_info[0].belong_project
    module = test_info[0].belong_module

    module_info = ModuleInfo.objects.filter(belong_project__project_name=project).order_by('-create_time')
    modules = list(module_info)

    case_info = TestCaseInfo.objects.filter(belong_project=project, belong_module=module, type=1).order_by('-create_time')
    cases = list(case_info)

    configs = TestCaseInfo.objects.filter(belong_project=project, belong_module=module, type=2).order_by('-create_time')
    configs = list(configs)
    query_data = {}
    devops_modules = devops_api.get_module(query_data).get('data')
    # devops_modules = []
    manage_info = {
        'account': account,
        'info': test_info[0],
        'request': request['test'],
        'include': include,
        'project': ProjectInfo.objects.all().values('project_name').order_by('-create_time'),
        'modules': modules,
        'cases': cases,
        'configs': configs,
        'env': EnvInfo.objects.all().order_by('-create_time'),
        'devops_modules': devops_modules
    }
    return render_to_response('edit_case.html', manage_info)
Esempio n. 3
0
def add_logic_case(request):
    account = request.session["now_account"]
    if request.is_ajax():
        testcase_info = json.loads(request.body.decode('utf-8'))
        msg = logic_test_case(**testcase_info)
        return HttpResponse(get_ajax_msg(msg, '/api/test_logic_list/1/'))
    elif request.method == 'GET':
        query_data = {}
        devops_modules =devops_api.get_module(query_data).get('data')
        # devops_modules =[]
        manage_info = {
            'account': account,
            'project': ProjectInfo.objects.all().values('project_name').order_by('-create_time'),
            'env': EnvInfo.objects.all().order_by('-create_time'),
            'devops_modules': devops_modules
        }
        return render_to_response('add_logic_case.html', manage_info)
Esempio n. 4
0
def copy_logic_case(request, id=None):
    account = request.session["now_account"]
    user_type = request.session['user_type']

    test_info = TestCaseInfo.objects.get_case_by_id(id)
    request = eval(test_info[0].request)
    include = eval(test_info[0].include)

    project = test_info[0].belong_project
    module = test_info[0].belong_module

    module_info = ModuleInfo.objects.filter(belong_project__project_name=project).order_by('-create_time')
    modules = list(module_info)

    case_info = TestCaseInfo.objects.filter(belong_project=project, belong_module=module, type=1).order_by('-create_time')
    cases = list(case_info)

    configs = TestCaseLogicInfo.objects.filter(belong_project=project, belong_module=module, type=2).order_by('-create_time')
    configs = list(configs)
    query_data = {}
    devops_modules = devops_api.get_module(query_data).get('data')
    # devops_modules = []

    testinfo = test_info[0]
    testinfo.id = None
    testinfo.author = account
    manage_info = {
        'account': account,
        'info': testinfo,
        'request': request['test'],
        'include': include,
        'project': ProjectInfo.objects.all().values('project_name').order_by('-create_time'),
        'modules': modules,
        'cases': cases,
        'configs': configs,
        'env': EnvInfo.objects.all().order_by('-create_time'),
        'devops_modules': devops_modules
    }
    return render_to_response('edit_logic_case.html', manage_info)
Esempio n. 5
0
def list_devops_module(request):
    query_data = json.loads(request.body.decode('utf-8'))
    result = devops_api.get_module(query_data)
    return JsonResponse(result)