Esempio 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)
Esempio 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)
Esempio 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 = {}
Esempio n. 4
0
 def updateConfig(self, url, method, submit, header, data, deal, condition,
                  expect, assertion):
     try:
         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)
         db.session.commit()
     except Exception:
         db.session.rollback()
         raise UnknownException(msg='修改配置异常')
Esempio n. 5
0
 def write_case_excel(cls, cases, file_path):
     excel = OperationExcel(file_path)
     excel.get_sheet_write()
     for row in range(len(cases)):
         for col in range(len(cases[row])):
             if col == CaseExcelEnum.METHOD.value:
                 excel.write_execel(row + 1, col,
                                    CaseMethodEnum(cases[row][col]).name)
             elif col == CaseExcelEnum.SUBMIT.value:
                 excel.write_execel(row + 1, col,
                                    CaseSubmitEnum(cases[row][col]).name)
             elif col == CaseExcelEnum.DEAL.value:
                 excel.write_execel(row + 1, col,
                                    CaseDealEnum(cases[row][col]).name)
             elif col == CaseExcelEnum.ASSERTION.value:
                 excel.write_execel(row + 1, col,
                                    CaseAssertEnum(cases[row][col]).name)
             else:
                 excel.write_execel(row + 1, col, cases[row][col])
     excel.write_save()
Esempio n. 6
0
 def submit(self):
     return CaseSubmitEnum(self._submit).value