Esempio n. 1
0
 def get(self,request):
     """
     获取用例列表
     :param request:
     :return:
     """
     result=project_status_check(request)
     if result:
         return result
     project_id, group_id, name = request.GET.get('project_id'), request.GET.get(
         'test_case_group_id'), request.GET.get('name')
     if group_id:
         if not group_id.isdecimal():
             return JsonResponse(code=code.CODE_PARAMETER_ERROR)
         if name:
             objects=AutomationTestCase.objects.filter(project=project_id,case_name__contains=name,test_case_group=group_id).order_by('id')
         else:
             objects=AutomationTestCase.objects.filter(project=project_id,test_case_group=group_id).order_by('id')
     else:
         if name:
             objects = AutomationTestCase.objects.filter(project=project_id, case_name__contains=name).order_by('id')
         else:
             objects = AutomationTestCase.objects.filter(project=project_id).order_by('id')
     result = objects_paginator(request, objects)
     serialize = TestCaseSerializer(result['obm'], many=True)
     return JsonResponse(data={"data": serialize.data,
                               "page": result['page'],
                               "total": result['total']
                               }, code=code.CODE_SUCCESS)
Esempio n. 2
0
    def get(self, request):
        result = project_status_check(request)
        if result:
            return result
        project_id, api_group_id, name = request.GET.get(
            'project_id'), request.GET.get('api_group_id'), request.GET.get(
                'name')
        if api_group_id:
            if not api_group_id.isdecimal():
                return JsonResponse(code=code.CODE_PARAMETER_ERROR)
            if name:
                objects = APIInfo.objects.filter(
                    project=project_id,
                    name__contains=name,
                    api_group=api_group_id).order_by('id')
            else:
                objects = APIInfo.objects.filter(
                    project=project_id, api_group=api_group_id).order_by('id')
        else:
            if name:
                objects = APIInfo.objects.filter(
                    project=project_id, name__contains=name).order_by('id')
            else:
                objects = APIInfo.objects.filter(
                    project=project_id).order_by('id')

        result = objects_paginator(request, objects)
        serialize = APIInfoListSerializer(result['obm'], many=True)
        return JsonResponse(data={
            "data": serialize.data,
            "page": result['page'],
            "total": result['total']
        },
                            code=code.CODE_SUCCESS)
Esempio n. 3
0
 def get(self, request):
     """
     获取用例接口的列表
     :param request:
     :return:
     """
     result = project_status_check(request)
     if result:
         return result
     project_id, case_id = request.GET.get('project_id'), request.GET.get(
         'case_id')
     try:
         AutomationTestCase.objects.get(id=case_id, project=project_id)
     except ObjectDoesNotExist:
         return JsonResponse(code="999987", msg="测试用例不存在!")
     objects = AutomationCaseApi.objects.filter(
         automation_test_case=case_id).order_by('id')
     result = objects_paginator(request, objects)
     serialize = AutomationCaseApiListSerializer(result['obm'], many=True)
     for i in range(len(serialize.data) - 1):
         serialize.data[i]['testStatus'] = False
     return JsonResponse(data={
         "data": serialize.data,
         "page": result['page'],
         "total": result['total']
     },
                         code=code.CODE_SUCCESS)
Esempio n. 4
0
 def get(self, request):
     """
     获取接口关联数据
     :param request:
     :return:
     """
     result = project_status_check(request)
     if result:
         return result
     project_id, case_id, api_id = request.GET.get(
         'project_id'), request.GET.get('case_id'), request.GET.get(
             'api_id')
     try:
         AutomationTestCase.objects.get(id=case_id, project=project_id)
     except ObjectDoesNotExist:
         return JsonResponse(code="999987", msg="测试用例不存在!")
     if api_id:
         data = CorrelationDataSerializer(AutomationCaseApi.objects.filter(
             automation_test_case=case_id, id__lt=api_id),
                                          many=True).data
     else:
         data = CorrelationDataSerializer(
             AutomationCaseApi.objects.filter(automation_test_case=case_id),
             many=True).data
     return JsonResponse(code=code.CODE_SUCCESS, data=data)
Esempio n. 5
0
 def get(self, request):
     """
     获取接口详情
     :param request:
     :return:
     """
     result = project_status_check(request)
     if result:
         return result
     project_id, case_id, api_id = request.GET.get(
         'project_id'), request.GET.get('case_id'), request.GET.get(
             'api_id')
     try:
         AutomationTestCase.objects.get(id=case_id, project=project_id)
     except ObjectDoesNotExist:
         return JsonResponse(code="999987", msg="测试用例不存在!")
     try:
         case_api = AutomationCaseApi.objects.get(
             id=api_id, automation_test_case=case_id)
     except ObjectDoesNotExist:
         return JsonResponse(code="999987", msg="用例接口不存在!")
     data = AutomationCaseApiSerializer(case_api).data
     try:
         name = AutomationResponseJson.objects.get(
             automation_case_api=api_id, type="Regular")
         data['RegularParam'] = name.name
     except ObjectDoesNotExist:
         pass
     return JsonResponse(code=code.CODE_SUCCESS, data=data)
Esempio n. 6
0
 def get(self, request):
     """
     获取接口详情
     :param request:
     :return:
     """
     api_id = request.GET.get('api_id')
     if not api_id or not api_id.isdecimal():
         return JsonResponse(code=code.CODE_PARAMETER_ERROR)
     result = project_status_check(request)
     if result:
         return result
     try:
         api_info = APIInfo.objects.get(
             id=api_id, project=request.GET.get('project_id'))
         serializer = APIInfoSerializer(api_info)
         return JsonResponse(data=serializer.data, code=code.CODE_SUCCESS)
     except ObjectDoesNotExist:
         return JsonResponse(code=code.CODE_OBJECT_NOT_EXIST, msg='接口不存在')
Esempio n. 7
0
 def get(self, request):
     """
     获取成员列表
     :param request:
     :return:
     """
     result = project_status_check(request)
     if result:
         return result
     objects = ProjectMember.objects.filter(
         project=request.GET.get('project_id')).order_by('id')
     result = objects_paginator(request, objects)
     serialize = ProjectMemberSerializer(result['obm'], many=True)
     return JsonResponse(data={
         "data": serialize.data,
         "page": result['page'],
         "total": result['total']
     },
                         code=code.CODE_SUCCESS)
Esempio n. 8
0
 def get(self,request):
     """
     获取测试结果
     :param request:
     :return:
     """
     project_id,case_id,api_id=request.GET.get('project_id'),request.GET.get('case_id'),request.GET.get('api_id')
     result=project_status_check(request)
     if result:
         return result
     try:
         AutomationTestCase.objects.get(id=case_id,project_id=project_id)
     except ObjectDoesNotExist:
         return JsonResponse(code=code.CODE_OBJECT_NOT_EXIST,msg="用例不存在")
     try:
         AutomationCaseApi.objects.get(id=api_id,automation_test_case=case_id)
     except ObjectDoesNotExist:
         return JsonResponse(code=code.CODE_OBJECT_NOT_EXIST,msg="接口不存在")
     try:
         data=AutomationTestResult.objects.get(automation_case_api=api_id)
         serializer=AutomationTestResultSerializer(data)
         return JsonResponse(data=serializer.data,code=code.CODE_SUCCESS)
     except ObjectDoesNotExist:
         return JsonResponse(code=code.CODE_Failed)