Ejemplo n.º 1
0
class TestSuite(db.Model):
    __tablename__ = 'p_test_suite'
    sid = db.Column(db.Integer,
                    primary_key=True,
                    autoincrement=True,
                    unique=True,
                    comment='测试集ID')
    s_name = db.Column(db.String(50), nullable=False, comment='模块名称或测试集名称')
    s_desc = db.Column(db.String(150), nullable=False, comment='测试集描述')

    create_time = db.Column(db.DateTime,
                            default=datetime.datetime.now(),
                            comment='创建时间')
    update_time = db.Column(db.DateTime,
                            default=datetime.datetime.now,
                            onupdate=datetime.datetime.now,
                            comment='更新时间')
    p_creator = db.Column(db.String(50), nullable=False, comment='创建者')
    p_id = db.Column(db.Integer,
                     db.ForeignKey('project.p_id', ondelete='CASCADE'),
                     comment='项目ID')
    suite_case = db.relationship('SuiteCase',
                                 backref=db.backref('p_test_suite'),
                                 lazy='dynamic',
                                 cascade='all, delete-orphan')

    def __init__(self, s_name, p_creator, p_id, s_desc=''):
        self.s_name = s_name
        self.p_creator = p_creator
        self.p_id = p_id
        self.s_desc = s_desc

    def __repr__(self):
        return '<Suite ID:%r>' % self.sid
Ejemplo n.º 2
0
class Project(db.Model):
    __tablename__ = "project"
    p_id = db.Column(db.Integer,
                     primary_key=True,
                     autoincrement=True,
                     unique=True,
                     comment='项目ID')
    p_name = db.Column(db.String(50), nullable=False, comment='项目名称')
    create_time = db.Column(db.DateTime,
                            default=datetime.datetime.now(),
                            comment='创建时间')
    update_time = db.Column(db.DateTime,
                            default=datetime.datetime.now,
                            onupdate=datetime.datetime.now,
                            comment='更新时间')
    p_creator = db.Column(db.String(50), nullable=False, comment='创建者')
    p_status = db.Column(db.Integer, nullable=False, default=0, comment='项目状态')
    p_desc = db.Column(db.String(150), nullable=False, comment='项目描述')
    user_id = db.Column(db.Integer,
                        db.ForeignKey('user.uid', ondelete='RESTRICT'),
                        comment='用户ID')
    test_suite = db.relationship('TestSuite',
                                 backref=db.backref('project'),
                                 lazy='dynamic',
                                 cascade='all, delete-orphan')

    def __init__(self, p_name, p_creator, user_id, p_desc):
        self.p_name = p_name
        self.p_creator = p_creator
        self.user_id = user_id
        self.p_desc = p_desc

    def __repr__(self):
        return "<ProjectID:%r>" % self.p_id
Ejemplo n.º 3
0
class CaseInterface(Case):
    __tablename__ = 'case_interface'
    c_method = db.Column(db.String(10), nullable=False, comment='请求方式')
    c_url = db.Column(db.Text, nullable=False, comment='请求地址')
    c_headers = db.Column(db.Text, nullable=False, comment='请求头信息')
    c_body = db.Column(db.Text, nullable=False, comment='请求主体')
    sid = db.Column(db.Integer, db.ForeignKey(''), comment='测试集')

    suites = db.relationship('TestSuite', secondary='suite_case', backref='caseInterfaces')
Ejemplo n.º 4
0
class SuiteCase(db.Model):
    __tablename__ = 'suite_case_interface'
    scid = db.Column(db.Integer,
                     primary_key=True,
                     autoincrement=True,
                     unique=True,
                     comment='场景用例ID')
    scName = db.Column(db.String(128), nullable=False, comment='用例名称')
    scNo = db.Column(db.Integer, nullable=True, comment='用例在场景中的序顺号')
    create_time = db.Column(db.DateTime,
                            default=datetime.datetime.now(),
                            comment='创建时间')
    update_time = db.Column(db.DateTime,
                            default=datetime.datetime.now,
                            onupdate=datetime.datetime.now,
                            comment='更新时间')
    p_creator = db.Column(db.String(20), nullable=False, comment='创建者')
    uid = db.Column(db.Integer, nullable=False, comment='创建者ID')
    scDesc = db.Column(db.String(200), nullable=False, comment="用例描述")
    scMethod = db.Column(db.String(10), nullable=False, comment='请求方式')
    scUrl = db.Column(db.Text, nullable=False, comment='请求地址')
    scHeaders = db.Column(db.Text, nullable=False, comment='请求头信息')
    scBody = db.Column(db.Text, nullable=False, comment='请求主体')
    case_assert = db.relationship('Suite_Case_Assert',
                                  backref=db.backref('suite_case_interface'),
                                  lazy='dynamic',
                                  cascade='all, delete-orphan')
    case_result = db.relationship('Suite_Case_Result',
                                  backref=db.backref('suite_case_interface'),
                                  lazy='dynamic',
                                  cascade='all, delete-orphan')
    case_out_param = db.relationship(
        'Suite_Case_Output_Parameter',
        backref=db.backref('suite_case_interface'),
        lazy='dynamic',
        cascade='all, delete-orphan')
    sid = db.Column(db.Integer,
                    db.ForeignKey('p_test_suite.sid', ondelete='CASCADE'),
                    comment='场景ID')

    def __init__(self, scName, scNo, p_creator, uid, scDesc, scMethod, scUrl,
                 scHeaders, scBody, sid):
        self.scName = scName
        self.scNo = scNo
        self.p_creator = p_creator
        self.uid = uid
        self.scDesc = scDesc
        self.scMethod = scMethod
        self.scUrl = scUrl
        self.scHeaders = scHeaders
        self.scBody = scBody
        self.sid = sid
Ejemplo n.º 5
0
class Case_Result(db.Model):
    __tablename__ = 'case_result'
    r_id = db.Column(db.Integer,
                     primary_key=True,
                     autoincrement=True,
                     comment='测试结果ID')
    c_id = db.Column(db.Integer,
                     db.ForeignKey('case_interface.c_id', ondelete='CASCADE'),
                     comment='用例ID')
    response_header = db.Column(db.Text, nullable=False, comment='响应头信息')
    response_body = db.Column(db.Text, nullable=False, comment='响应body')
    response_cookies = db.Column(db.Text, nullable=False, comment='响应cookie')
    response_datatime = db.Column(db.String(50), comment='响应时间(毫秒)')
Ejemplo n.º 6
0
class Case_Output_Parameter(db.Model):
    __tablename__ = 'case_output_parameter'
    o_id = db.Column(db.Integer,
                     primary_key=True,
                     autoincrement=True,
                     comment='输出参数ID')
    c_id = db.Column(db.Integer,
                     db.ForeignKey('case_interface.c_id', ondelete='CASCADE'),
                     comment='用例ID')
    o_name = db.Column(db.String(100), nullable=False, comment='出参名称')
    o_soucre = db.Column(db.Integer, nullable=False, comment='出参来源')
    o_analytical_exp = db.Column(db.Text, nullable=False, comment='解析表达式')
    o_match = db.Column(db.Integer, nullable=False, comment='第几个匹配')
Ejemplo n.º 7
0
class Case_Assert(db.Model):
    __tablename__ = 'case_assert'
    a_id = db.Column(db.Integer,
                     primary_key=True,
                     autoincrement=True,
                     comment='断言ID')
    c_id = db.Column(db.Integer,
                     db.ForeignKey('case_interface.c_id', ondelete='CASCADE'),
                     comment='用例ID')
    check_type = db.Column(db.Integer, nullable=False, comment='断言类型')
    check_object = db.Column(db.Text, nullable=False, comment='断言对象')
    check_condition = db.Column(db.Integer, nullable=False, comment='断言条件')
    check_content = db.Column(db.Text, nullable=False, comment='断言内容')
    check_result = db.Column(db.String(20), nullable=False, comment='断言结果')
Ejemplo n.º 8
0
class Post(db.Model):
    __tablename__ = 'post'
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    created = db.Column(db.Date, nullable=False)
    title = db.Column(db.String(20), nullable=False)
    body = db.Column(db.String(100), nullable=False)
    author_id = db.Column(db.Integer,
                          db.ForeignKey('user.uid'),
                          nullable=False)
    users = db.relationship('User', backref=db.backref('posts'))

    def __init__(self, title, content, author_id):
        self.title = title
        self.content = content
        self.author_id = author_id

    def __repr__(self):
        return '<Category %r>' % self.title
Ejemplo n.º 9
0
class Variable(db.Model):
    """
    变量表
    """
    __tablename__ = 'variableglobal'
    vid = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(50), nullable=False)
    value = db.Column(db.String(255), nullable=False)
    uid = db.Column(
        db.Integer, 
        db.ForeignKey('user.uid', ondelete='CASCADE'), 
        comment='用户ID'
    )

    def __init__(self, name, value, uid):
        self.name = name
        self.value = value
        self.uid = uid
Ejemplo n.º 10
0
class TestSuite(db.Model):
    __tablename__ = 'p_test_suite'
    sid = db.Column(db.Integer, primary_key=True, autoincrement=True, unique=True, comment='测试集ID')
    s_name = db.Column(db.String(50), nullable=False, comment='模块名称或测试集名称')

    create_time = db.Column(db.DateTime, default=datetime.datetime.now(), comment='创建时间')
    update_time = db.Column(
        db.DateTime, 
        default=datetime.datetime.now, 
        onupdate=datetime.datetime.now, 
        comment='更新时间'
        )
    p_creator = db.Column(db.String(50), nullable=False, comment='创建者')
    p_id = db.Column(db.Integer, db.ForeignKey('project.p_id', ondelete='CASCADE'), comment='项目ID')

    def __init__(self, s_name, p_creator, p_id):
        self.s_name = s_name
        self.p_creator = p_creator
        self.p_id = p_id

    def __repr__(self):
        return '<Suite ID:%r>' % self.sid
Ejemplo n.º 11
0
import datetime
from qtpp import db

class Role(db.Model):
    
    __tablename__='role'
    r_id=db.Column(db.Integer,autoincrement=True, primary_key=True)
    r_name=db.Column(db.String(10))
    users=db.relationship('User',backref='role')


#角色和权限的(多对多的)关联表
#r_p为关联表的表名
r_p=db.Table(
    'r_p',
    db.Column('role_id',db.Integer,db.ForeignKey('role.r_id'), primary_key=True),
    db.Column('permission_id',db.Integer,db.ForeignKey('permission.p_id'), primary_key=True)
)


#权限模型表
class Permission(db.Model):
    __tablename__='permission'
    p_id=db.Column(db.Integer,autoincrement=True, primary_key=True)
    p_name=db.Column(db.String(16), unique=True)
    p_er=db.Column(db.String(16), unique=True)
    #添加多对多的反向引用,必须使用secondary指定中间关联表
    #用权限查询角色时用查询到的权限对象:“权限对象.roles.all()”得到其对应的所有角色
    roles=db.relationship('Role', secondary=r_p, backref=db.backref('permission', lazy=True))
    #db.backref('permission', 中的permission用来反向关联,用角色查询其对应的所有权限。用查询到的 '角色对象.permission.all()'得到。
    ###relationship可以放到任意一个类中都行,与之相反。###
Ejemplo n.º 12
0

class Case(db.Model):
    __abstract__ = True
    c_id = db.Column(db.Integer, primary_key=True, autoincrement=True, comment='用例ID')
    c_name = db.Column(db.String(128), nullable=False, comment='用例名称')
    create_time = db.Column(db.DateTime, default=datetime.datetime.now, comment='创建时间')
    update_time = db.Column(
        db.DateTime, 
        default=datetime.datetime.now, 
        onupdate=datetime.datetime.now, 
        comment='更新时间'
        )


class CaseInterface(Case):
    __tablename__ = 'case_interface'
    c_method = db.Column(db.String(10), nullable=False, comment='请求方式')
    c_url = db.Column(db.Text, nullable=False, comment='请求地址')
    c_headers = db.Column(db.Text, nullable=False, comment='请求头信息')
    c_body = db.Column(db.Text, nullable=False, comment='请求主体')
    sid = db.Column(db.Integer, db.ForeignKey(''), comment='测试集')

    suites = db.relationship('TestSuite', secondary='suite_case', backref='caseInterfaces')


suite_case = db.Table(
    'suite_case',
    db.Column('c_id', db.Integer, db.ForeignKey('case_interface.c_id'), comment='用例ID'),
    db.Column('sid', db.Integer, db.ForeignKey('p_test_suite.sid'), comment='测试集ID')
    )