Esempio n. 1
0
def add():
    form = CaseForm()
    if form.validate_on_submit():

        case = Case(name=form.name)
        form.populate_obj(case)
        case.author = current_user
        case.save()
        flash("Add Test Case successfully")
        return redirect(url_for("case.view", case_id=case.id))
    return render_template("case/add.html", form=form)
Esempio n. 2
0
def add_case():

    if not request.json or not 'name' in request.json:
        abort(400)

    case = Case(name=request.json['name'])
    #case.author = current_user
    user = User.query.filter_by(username=request.json['username']).first_or_404()
    case.author = user

    case.description = request.json['description']
    case.save()

    return jsonify({'case':str(case)}),201
Esempio n. 3
0
def case():
    form = AddPostForm()
    title = "Add Post"
    if form.validate_on_submit():
        category = form.category.data
        title = form.title.data
        description = form.description.data
        geolocation = form.geolocation.data
        status_id = 1

        if "photo" in request.files:
            pic = photos.save(request.files["photo"])
            file_path = f"photos/{pic}"
            image = file_path
        post = Case(category=category,
                    title=title,
                    description=description,
                    geolocation=geolocation,
                    image=image,
                    status_id=status_id)
        db.session.add(post)
        db.session.commit()
        return redirect(url_for(".dashboard"))

    return render_template("add_incidences.html", form=form, title=title)
Esempio n. 4
0
    def populate_sample_data(self):
        utcnow = datetime.utcnow()
        case = Case(case_name=r"Animal/Bunch", date_opened=utcnow)
        self.case = case
        self.update_db(case)

        a = Person(first_name="Andrew", last_name="Aardvark", case=case)
        b = Person(first_name="Bonnie", last_name="Badger", case=case)
        c = Person(first_name="Clyde", last_name="Crocodile", case=case)
        self.people = {'a': a, 'b': b, 'c': c}
        self.update_db(a)
        self.update_db(b)
        self.update_db(c)

        log1 = PhoneLogEntry(timestamp=utcnow + timedelta(minutes=01),
                             case=case,
                             content="hello 01",
                             caller=a)
        log2 = PhoneLogEntry(timestamp=utcnow + timedelta(minutes=02),
                             case=case,
                             content="hello 02",
                             caller=a)
        log3 = PhoneLogEntry(timestamp=utcnow + timedelta(minutes=03),
                             case=case,
                             content="hello 03",
                             caller=c)
        log4 = PhoneLogEntry(timestamp=utcnow + timedelta(minutes=04),
                             case=case,
                             content="hello 04",
                             caller=a)
        self.update_db(log1)
        self.update_db(log2)
        self.update_db(log3)
        self.update_db(log4)
Esempio n. 5
0
def modify_case(caseId):

    form = request.get_json()
    name = form.get('c_name', '')
    desc = form.get('c_desc', '')
    setup = form.get('setup', None)
    teardown = form.get('teardown', None)
    params = form.get('c_query', '')
    headers = form.get('c_header', '')
    body = form.get('c_body', '')
    asserts = form.get('c_assert', '')
    tmp_param = form.get('c_save_param', '')

    # 查询数据库中apiId=apiId的项目信息
    db_case = Case.find_by_id(caseId)
    if not db_case:
        return jsonify({"code": 400, "msg": "caseId不存在"})

    db_case.c_name = name
    db_case.c_desc = desc
    db_case.setup = str(setup)
    db_case.teardown = str(teardown)
    db_case.c_query = params
    db_case.c_header = str(headers)
    db_case.c_body = str(body)
    db_case.c_assert = str(asserts)
    db_case.c_save_param = tmp_param
    try:
        db.session.commit()
        return jsonify({'msg': '编辑成功', 'code': 200})
    except Exception as e:
        db.session.rollback()
        return jsonify({'msg': str(e), 'code': 500})
Esempio n. 6
0
def create(default_data=True, sample_data=False):
    "Creates database tables from sqlalchemy models"
    db.create_all()

    ray = add_user(username="******", password="******", email="*****@*****.**")
    simon = add_user(username="******", password="******", email="*****@*****.**")
    xiang = add_user(username="******", password="******", email="*****@*****.**")

    case = Case(name="TestCase001", author_id=ray.id,
        description = "This is the first test case"
    )
    case.save()

    result = Result(name="TestResult001" , author_id=ray.id,
        link="http://www.baidu.com", case_id=case.id
    )
    result.save()
Esempio n. 7
0
def addCase(chandao):
    data = request.values
    case = Case(name=data['casename'],
                content=data['casecontent'],
                task_chandao=chandao)
    db.session.add(case)
    db.session.commit()
    url = url_for('home.choiceTask', chandao=chandao)
    return url
Esempio n. 8
0
def add():
    form = CaseForm()
    if form.validate_on_submit():

        case = Case(name=form.name)
        form.populate_obj(case)
        case.author = current_user
        case.save()
        flash("Add Test Case successfully")
        return redirect(url_for("case.view", case_id=case.id))
Esempio n. 9
0
 def insert(case_id,behave_list):
     case_data = Case.objects(case_id=case_id).first()
     if case_data:
         for behave in behave_list:
             case_data.logs[behave] += behave_list[behave]
         case_data = self.update_case_status(case_data)
         case_data.save()
     else:
         error_string = '合同%s无申请记录,却进行%s操作日志' % (case_id, list(behave for behave in behave_list))
         self.insert_erro_log(logstring=error_string)
Esempio n. 10
0
 def setUp(self):
     self.client_Stephen = Client(full_name="Stephen Remmi",
                                  username="******",
                                  password="******",
                                  email="*****@*****.**")
     self.new_post = Case(post_title="Sample Title",
                          case_content="Hallo Welt! Ich bin hier",
                          client_id=self.client_Stephen.id)
     self.new_comment = Comment(comment="Nice job",
                                client_id=self.new_case.case_id,
                                client_id=self.client_Stephen.id)
Esempio n. 11
0
def create_case():
    # 创建用例

    form = request.get_json()
    name = form.get('c_name', '')
    desc = form.get('c_desc', '')
    setup = form.get('setup', '[]')
    teardown = form.get('teardown', '[]')
    params = form.get('c_query', '')
    headers = form.get('c_header', '')
    body = form.get('c_body', '')
    asserts = form.get('c_assert', '')
    tmp_param = form.get('c_save_param', '')
    api_id = form.get('api_id')

    if not name or not api_id:
        return jsonify({"code": 400, "msg": "参数错误"})

    userId = get_jwt_identity()
    new_case = Case(c_name=name,
                    c_desc=desc,
                    setup=str(setup),
                    teardown=str(teardown),
                    c_query=params,
                    c_body=str(body),
                    c_header=str(headers),
                    c_assert=str(asserts),
                    c_save_param=tmp_param,
                    api_id=api_id,
                    creator=userId)

    try:
        new_case.create()
        return jsonify({"code": 201, "msg": "创建用例成功"})
    except Exception as e:
        db.session.rollback()
        print(e)
        return jsonify({"code": 400, "msg": str(e)})
    finally:
        db.session.close()
Esempio n. 12
0
def cases():
    form = CaseForm()
    if form.submit.data:
        existcase = Case.query.filter_by(name=form.name.data,
                                         user=current_user).first()
        if existcase is not None:
            flash('案例名称<{}>已存在,添加失败。'.format(form.name.data))
        else:
            case = Case(name=form.name.data,
                        user=current_user,
                        quantitytype='single')
            db.session.add(case)
            db.session.commit()
            flash('案例<{}>添加成功.'.format(form.name.data))
Esempio n. 13
0
def create(default_data=True, sample_data=False):
    "Creates database tables from sqlalchemy models"
    db.create_all()

    ray = add_user(username="******", password="******", email="*****@*****.**")
    simon = add_user(username="******",
                     password="******",
                     email="*****@*****.**")
    xiang = add_user(username="******",
                     password="******",
                     email="*****@*****.**")

    case = Case(name="TestCase001",
                author_id=ray.id,
                description="This is the first test case")
    case.save()

    result = Result(name="TestResult001",
                    author_id=ray.id,
                    link="http://www.baidu.com",
                    case_id=case.id)
    result.save()
Esempio n. 14
0
def case_add():
    form = CaseFrom()
    if form.validate_on_submit():
        data = form.data
        if Case.query.filter_by(cases_name=data['cases_name']).count() == 1:
            flash('用例名称已存在!', category='err')
            return redirect(url_for('admin.case_add'))
        case = Case(cases_name=data["cases_name"],
                    version=data["version"],
                    models=data["models"],
                    url=data["RequestAddress"],
                    data=data["RequestData"],
                    sql=data["RequestSql"],
                    code=data["code"],
                    actually='',
                    sql_result='',
                    result='',
                    msg='',
                    user_id=session["admin"],
                    method=data["RequestMethod"],
                    case_leader=data["case_leader"],
                    comment=data["comment"],
                    Environment=data["Environment"],
                    pass_num='',
                    fail_num='',
                    execute_count='',
                    case_pass='',
                    status=0)
        db.session.add(case)
        db.session.commit()
        flash("添加用例成功!", "ok")
        oplog = Oplog(admin_id=session["admin_id"],
                      ip=request.remote_addr,
                      reason="添加用例:%s" % data['cases_name'])
        db.session.add(oplog)
        db.session.commit()
    return render_template("admin/case_add.html", form=form)
Esempio n. 15
0
    def __create(self, args):
        result = {"status": "success", "msg": "操作成功"}

        case = Case.query.filter(
            and_(Case.name == args["name"],
                 Case.suite_id == args["suite_id"])).first()
        if case is None:
            try:
                case = Case(name=args["name"],
                            desc=args["desc"],
                            suite_id=args["suite_id"],
                            tags=args["tags"],
                            enable=args["enable"],
                            setup=args["setup"],
                            teardown=args["teardown"],
                            create_user_id=current_user.get_id(),
                            update_user_id=current_user.get_id())

                db.session.add(case)
                db.session.commit()
                result["suite_id"] = case.suite_id
            except Exception as e:
                result["status"] = "fail"
                result["msg"] = "异常:%s" % str(e)
Esempio n. 16
0
        def struct_case(case):
            if not case['start_date']:  # 计算是否是首借单
                first_case_flag = 0
            else:
                first_case_flag = 0 if is_first_case(start_date=case['start_date'], customer_id=case['customer_id'])[
                                           'signFrequency'] <= 1 else 1

            newcase = Case()
            newcase.create_time = case['create_time']
            newcase.case_id = case['apply_sn']
            newcase.customer_id = case['customer_id']
            newcase.customer_name = case['customer_name']
            newcase.ic_number = case['ic_number']
            newcase.is_renew_case = first_case_flag
            newcase.amount = case['amount']
            newcase.start_date = case['start_date']
            newcase.end_date = case['end_date']
            newcase.case_tenor = case['tenor']
            newcase.sale_name = case['SALES_NAME']
            newcase.risk_manager_name = case['risk_manager_name']
            newcase.approver = case['approver']
            newcase.approve_time = case['approve_time']
            newcase.approve_status=None
            newcase.card_name = None
            newcase.shop_id = case['shop_id']
            newcase.plateform_fee = case['platform_fee']
            newcase.guarantor_fee = case['guarantor_fee']
            newcase.service_fee1 = case['service_fee1']
            newcase.service_fee2 = case['service_fee2']
            newcase.risk_fee = case['risk_fee']
            newcase.case_status = []
            newcase.status_code = case['status']
            newcase.recommend_name = case['real_name']
            newcase.recommend_fee = case['referral_fee']
            newcase.logs = {'chushen': [], 'fushen': [], 'loan': [], 'diancui': [], 'waicui': [], 'daihuan_apply': [],
                            'daihuan_approve': [], 'inadvance_apply': [], 'inadvance_approve': [], 'refund': [],
                            'end': [], 'payment': []}
            newcase.save()
Esempio n. 17
0
 def approve_cases_update(self):
     retry_cases = Case.objects(approve_status='退单通过').all()
     retry_cases_id = list(case.case_id for case in retry_cases)
Esempio n. 18
0
def case_detail(caseId):
    db_case = Case.find_by_id(caseId)
    api = db_case.api

    case_info = {**db_case.to_dict(), "url": api.a_url, "method": api.a_method}
    return case_info