Ejemplo n.º 1
0
    def edit_case(self, name, info, url, method, submit, header, data, deal,
                  condition, expect, assertion, type):

        old_case = Case(self.case_group, self.name, self.info, self.url,
                        self.method, self.submit, self.header, self.data,
                        self.deal, self.condition, self.expect, self.assertion,
                        self.type)
        old_case.id = self.id

        if self.name != name:
            if Case.query.filter_by(name=name,
                                    case_group=self.case_group,
                                    delete_time=None).first():
                raise ParameterException(msg='当前组已存在同名用例,请更改用例名称')
        # 用例名称暂时不允许修改
        # self.name = name
        self.info = info
        self.url = url
        self.method = CaseMethodEnum(method)
        self.submit = CaseSubmitEnum(submit)
        self.header = header
        self.data = data
        self.deal = CaseDealEnum(deal)
        self.condition = condition
        self.expect = expect
        self.assertion = CaseAssertEnum(assertion)
        self.type = CaseTypeEnum(type)
        self.update_user = get_current_user().id
        db.session.commit()

        self.edit_log(old_case)
Ejemplo n.º 2
0
 def __init__(self,
              project_id,
              order,
              case_id,
              name,
              is_run=True,
              info=None,
              url=None,
              method=1,
              submit=1,
              header=None,
              data=None,
              deal=1,
              condition=None,
              expect=None,
              assertion=1,
              case_type=1):
     super().__init__()
     self.project_id = project_id
     self.order = order
     self.case_id = case_id
     self.name = name
     self.is_run = is_run
     self.info = info
     self.url = url
     self.method = CaseMethodEnum(method)
     self.submit = CaseSubmitEnum(submit)
     self.header = header
     self.data = data
     self.deal = CaseDealEnum(deal)
     self.condition = condition
     self.expect = expect
     self.assertion = CaseAssertEnum(assertion)
     self.type = CaseTypeEnum(case_type)
Ejemplo n.º 3
0
 def __init__(self,
              case_group,
              name=None,
              info=None,
              url=None,
              method=1,
              submit=1,
              header=None,
              data=None,
              deal=1,
              condition=None,
              expect=None,
              assertion=1,
              case_type=1):
     super().__init__()
     self.name = name
     self.info = info
     self.url = url
     self.method = CaseMethodEnum(method)
     self.submit = CaseSubmitEnum(submit)
     self.header = header
     self.data = data
     self.deal = CaseDealEnum(deal)
     self.condition = condition
     self.expect = expect
     self.assertion = CaseAssertEnum(assertion)
     self.type = CaseTypeEnum(case_type)
     self.case_group = case_group
     self.create_user = get_current_user().id if get_current_user(
     ) else None
     self.update_user = get_current_user().id if get_current_user(
     ) else None
     self.actual_result = False
     self.reason = None
     self.result = {}
Ejemplo n.º 4
0
def enum_type():
    form = EnumTypeForm().validate_for_api()
    if form.type.data == 'METHOD':
        return CaseMethodEnum.data()
    elif form.type.data == 'SUBMIT':
        return CaseSubmitEnum.data()
    elif form.type.data == 'DEAL':
        return CaseDealEnum.data()
    elif form.type.data == 'TYPE':
        return CaseTypeEnum.data()
    elif form.type.data == 'ASSERT':
        return CaseAssertEnum.data()
    else:
        return {
            'METHOD': CaseMethodEnum.data(),
            'SUBMIT': CaseSubmitEnum.data(),
            'DEAL': CaseDealEnum.data(),
            'TYPE': CaseTypeEnum.data(),
            'ASSERT': CaseAssertEnum.data(),
        }
Ejemplo n.º 5
0
 def type(self):
     return CaseTypeEnum(self._type).value
Ejemplo n.º 6
0
        'create_time': task.create_time,
        # celery 中获取不到当前用户  只能从dealy传入
        'create_user': user.id,
        'username': user.username,
        'data': case.data,
        'deal_text': CaseDealEnum.data()[case.deal],
        'deal': case.deal,
        'expect': case.expect,
        'header': case.header,
        'info': case.info,
        'method_text': CaseMethodEnum.data()[case.method],
        'method': case.method,
        'reason': case.reason,
        'submit_text': CaseSubmitEnum.data()[case.submit],
        'submit': case.submit,
        'type': CaseTypeEnum.data()[case.type],
        'url': case.url,
        'result': case.result,
        'project_id': project.id,
        'project_name': project.name,
        'project_type': project.type,
        'project_type_name': ProjectTypeEnum.data()[project.type],
        'task_id': task.id,
        'task_no': task.task_no,
        'deal_result': case.deal_result
    }
    return case_log


def log_format(case_log):
    return {