Example #1
0
    def used_by_project(self):
        from app.models.ConfigCopy import ConfigCopy
        from app.models.ConfigRelation import ConfigRelation
        pid_list = []
        copy_configs = ConfigCopy.query.filter_by(case_id=self.id,
                                                  delete_time=None).all()
        for config in copy_configs:
            pid_list.append(config.project_id)

        relation_configs = ConfigRelation.query.filter_by(
            case_id=self.id, delete_time=None).all()
        for config in relation_configs:
            pid_list.append(config.project_id)

        project_list = []
        for pid in pid_list:
            from app.models.project import Project
            project = Project.query.filter_by(id=pid).first()
            p = {
                'name': project.name,
                'id': pid,
                'type': project.type,
                'type_name': ProjectTypeEnum.data()[project.type],
            }
            project_list.append(p)

        return project_list
Example #2
0
    def new_project(cls, form):
        project = cls.query.filter_by(name=form.name.data,
                                      delete_time=None).first()
        if project is not None:
            raise ParameterException(msg='工程已存在')
        # 新增分组的时候同时新增可查看当前用例组的人员。当出现问题时进行回滚,人员和分组都不插入
        try:
            project = Project()
            project.name = form.name.data
            project.server = form.server.data
            project.header = form.header.data
            project.info = form.info.data
            project.progress = 0
            project.type = ProjectTypeEnum(form.type.data)
            project.user = form.user.data
            project.running = False
            project.send_email = form.sendEmail.data
            project.email_strategy = EmailStrategyEnum(form.emailStrategy.data)
            project.copy_person = form.copyPerson.data
            db.session.add(project)
            db.session.flush()
            if form.users.data:
                for user in form.users.data:
                    user_auth = UserAuth()
                    user_auth.user_id = user
                    user_auth.auth_id = project.id
                    user_auth.type = UserAuthEnum.PROJECT
                    db.session.add(user_auth)
            db.session.commit()
        except Exception as e:
            db.session.rollback()
            raise UnknownException(msg='新增异常 数据已回滚')

        return True
Example #3
0
        '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 {
        'id': case_log['id'],
        'case_group': case_log['case_group'],
        'case_group_name': case_log['case_group_name'],
        'name': case_log['name'],
        'actual_result': case_log['actual_result'],
        'assertion_text': case_log['assertion_text'],
Example #4
0
 def type(self):
     return ProjectTypeEnum(self._type).value
Example #5
0
def enum_type():
    form = EnumTypeForm().validate_for_api()
    if form.type.data == 'TYPE':
        return ProjectTypeEnum.data()
    else:
        raise ParameterException(msg='无目标类型')