Example #1
0
class User(Document):
    __collection__ = "AggregationUser"

    email = StringField(required=True)
    first_name = StringField(max_length=50, default=lambda: "Bernardo")
    last_name = StringField(max_length=50, default="Heynemann")
    is_admin = BooleanField(default=True)
    updated_at = DateTimeField(required=True, auto_now_on_insert=True, auto_now_on_update=True)
    number_of_documents = IntField()
    list_items = ListField(IntField())
Example #2
0
class ApiTestData(ProjectDataDocument):
    """
    测试数据统计表---因为性能问题,取消使用 2016-09-30
    """
    __collection__ = "api_test_data"

    was_successful = BooleanField()  # 是否是成功的
    total = IntField()
    failures = IntField()
    errors = IntField()
    skipped = IntField()
    run_time = StringField(max_length=1024)
Example #3
0
class SafetyTestReport(ProjectDataDocument):
    """
    安全测试报告
    """
    __collection__ = "safety_test_report"
    # project_name = StringField()  # 项目名,里面加上版本号,这个并不是具体的内部项目,和其它几种测试数据不同
    hack_tool = StringField()  # 用于hack的软件名称
    total_cnts = IntField()  # 总计次数
    success_cnts = IntField()  # 成功次数
    success_rate = FloatField()  # 成功率,冗余
    time_cycle = FloatField()  # 花费时间:s
    crack_rate = FloatField()  # 破解效率,冗余
    mark = StringField()  # 描述备注
Example #4
0
class LimitTestData(MyDocument):
    """
    测试数据统计表
    """
    __collection__ = "limit_test_data"

    # id = ObjectId()
    was_successful = BooleanField()  # 是否是成功的
    total = IntField()
    failures = IntField()
    errors = IntField()
    skipped = IntField()
    run_time = StringField(max_length=1024)

    organization = ReferenceField(
        reference_document_type=Organization)  # 数据所属的组织
Example #5
0
class PerformReport(MyDocument):
    """
    性能测试报告,已经作废,在bench中有专门的处理的了:2016-09-10
    waste
    """
    __collection__ = "perform_report"

    server_soft_ware = StringField(max_length=2048)
    server_host_name = StringField(max_length=2048)
    server_port = StringField(max_length=64)
    doc_path = StringField(max_length=2048)
    doc_length = IntField()  # 文档长度,bytes
    con_level = IntField()  # 并发量
    test_time_taken = FloatField()  # 消耗时间 seconds
    complete_req = IntField()  # 完成请求数
    failed_req = IntField()  # 失败请求数
    non_2xx_res = IntField()  # 非2xx请求数
    total_trans = IntField()  # 总传输数据量bytes
    html_trans = IntField()  # 总html传输数据量bytes
    req_per_sec = FloatField()  # 每秒请求量
    time_per_req = FloatField()  # 平均http请求响应时间:ms
    time_per_req_across = FloatField()  # 所有并发请求量耗时(平均事务响应时间):ms
    trans_rate = FloatField()  # 每秒传输数据量,Kbytes/sec

    organization = ReferenceField(
        reference_document_type=Organization)  # 数据所属的组织
Example #6
0
class OrgResourceCnt(OrgUserDataDocument):
    """
    当前组织使用资源的情况
    """
    __collection__ = 'org_resource_cnt'
    __lazy__ = False

    resource = ReferenceField(reference_document_type=ProductResource)
    r_name = StringField()  # 冗余
    cnt = IntField()
Example #7
0
class ShareProjectReport(OrgUserDataDocument, ProjectBaseDocument):
    """
    分享测试项目报告,只有拥有此share的ID流水号的,就可以访问此报告信息,
    永久性的
    """
    __collection__ = 'share_project_report'
    pro_id = StringField()  # 测试项目id
    stoken = StringField()  # 访问此报告时所需要的token串号,share token
    cnt = IntField()  # 被访问的次数
    mark = StringField()  # 关于此分享的备注信息
Example #8
0
class ProjectFeedBack(ProjectDataDocument):
    """
    项目相关的问题反馈
    """

    msg = StringField()
    # images = ListField()  # 图片列表
    # todo 语音和视频
    label = StringField()  # 关于问题的标记
    status = IntField()  # 处理的状态码
Example #9
0
class ResourceGroupLimit(OrgUserDataDocument):
    """
    每个账号的相应的资源的限额
    """

    __collection__ = 'resource_group_limit'
    __lazy__ = False

    resource = ReferenceField(reference_document_type=ProductResource)
    r_name = StringField()  # 冗余 ,资源名称
    limit = IntField()  # 目录创建的数目
Example #10
0
class ServiceStatus(MyDocument):
    """
    服务器开放的服务状态
    """
    __collection__ = "service_status"

    info_asset = ReferenceField(reference_document_type=InfoAsset)  # 所属资产,信息资产
    port = IntField()  # 端口号
    protocol = StringField()  # 协议名称
    status = StringField()  # 状态
    version = StringField  # 版本
Example #11
0
class UnitTestData(MyDocument):
    """
    测试数据统计表--插入时没有使用,没有使用ORM
    """
    __collection__ = "unit_test_data"

    pro_version = StringField(max_length=1024)  # 项目版本号:1.2.3.4
    was_successful = BooleanField()  # 是否是成功的
    total = IntField()
    failures = IntField()
    errors = IntField()
    skipped = IntField()
    run_time = FloatField()
    details = ListField(ReferenceField(UnitTestDataDetail))

    # 数据归属
    project = ReferenceField(reference_document_type=Project)  # 测试数据所属的项目
    project_name = StringField()  # 项目名称,冗余
    organization = ReferenceField(
        reference_document_type=Organization)  # 数据所属的组织
Example #12
0
    def test_from_son(self):
        field = IntField()

        expect(field.from_son(10)).to_equal(10)
        expect(field.from_son(10.0)).to_equal(10)
        expect(field.from_son(10.0230)).to_equal(10)
        expect(field.from_son("10")).to_equal(10)
Example #13
0
    def test_validate_enforces_integers(self):
        field = IntField()

        expect(field.validate(1)).to_be_true()
        expect(field.validate("1")).to_be_true()
        expect(field.validate("qwe")).to_be_false()
        expect(field.validate(None)).to_be_true()
Example #14
0
class MobileSafetyData(
        OrgUserDataDocument,
        HttpDocument,
        # OperationDocument
):
    """
    手机安全数据

    """

    __collection__ = 'mobile_safety_data'

    bs = StringField()  # charging battery status
    br = FloatField()  # 电池状态,"0.36",battery rate

    carrier = StringField()  # 运营商,"\U4e2d\U56fd\U8054\U901a";
    cellular = StringField()  # LTE;
    coun = StringField()  # CN;
    dn = StringField()  # "iPhone 6s"

    idf = StringField()  # 85BA4C903C16F7631;
    imei = StringField()  # 000000000000000;
    # ip = StringField()
    lang = StringField()  # "en-CN";
    sc_w = IntField()  # screen width
    sc_h = IntField()  # screen height
    # mScreen = StringField()  # 1242x2208;
    dType = StringField()  # iPhone;
    mac = StringField()  # "02:00:00:00";
    dModel = StringField()  # "iPhone8,2";
    osType = StringField()  # ios;
    # osVerInt =StringField()# "9.3.2";
    osVerRelease = StringField()  # "9.3.2";
    route = StringField()  # "24:3:b0";
    ssid = StringField()  # MyWIFI;
    # utc = StringField()  # "2016-07-18 06:51:53";
    uuid = StringField()  # "513DE79D-F20AB2F685A";

    c_time = DateTimeField()  # 客户端时间,东8时区
Example #15
0
class ApiReqDelay(MyDocument):
    """测试接口的延时
    """
    __collection__ = "api_req_delay"

    domain = StringField(max_length=2048)  # ms,基准域
    path = StringField(max_length=2048)  # ms,接口路径及参数
    delay = FloatField()  # ms,请求时间
    http_status = IntField()  # http状态值

    # 数据归属
    project = ReferenceField(reference_document_type=Project)
    project_name = StringField()  # 项目名称,冗余
    organization = ReferenceField(reference_document_type=Organization)
Example #16
0
class ExDataRecord(MyDocument):
    """
    实验数据的记录表
    """

    __collection__ = "ex_data_record"

    # --------------数据状态值记录-----------
    record_status = StringField(
        max_length=64)  # 数据的状态:reported,filted,experiment
    # --------------数据发现和登记期-----------
    custom_name = StringField(max_length=256)  # 用户名称
    captcha_id = StringField(max_length=64)
    event_start_time = DateTimeField()  # weblog产生开始时间
    event_end_time = DateTimeField()  # weblog产生结束时间
    event_reporter = StringField(max_length=256)  # 事件汇报人
    event_report_time = DateTimeField()  # 事件汇报时间
    track_class = StringField(max_length=64)
    js_version = StringField(max_length=16)
    js_tag_page = StringField(max_length=2048)  # 在bitbucket或者tower中的当前版本的修改标记
    css_version = StringField(max_length=16)
    css_tag_page = StringField(max_length=2048)  # 在bitbucket或者tower中的当前版本的修改标记
    # --------------数据过滤的采集备案期-----------
    data_collection_name = StringField(max_length=256)
    producers = StringField(max_length=256)
    ex_user = StringField(max_length=256)  # 数据收集人
    action_time = DateTimeField()  # 数据备案时间
    # event_time = DateTimeField()
    file_name = StringField(max_length=64)
    file_path = StringField(max_length=2048)  # 实验数据文件所在路径,以FTP的方式来共享
    file_size = IntField()
    record_cnt = IntField()  # 记录的数目
    # --------------数据实验期-----------
    researcher = StringField(max_length=256)  # 数据实验人
    researche_time = DateTimeField()  # 数据实验时间
    research_result = StringField(max_length=10240)  # 验证处理结果
class User(Document):
    email = StringField(required=True)
    first_name = StringField(db_field="whatever",
                             max_length=50,
                             default=lambda: "Bernardo")
    last_name = StringField(max_length=50, default="Heynemann")
    is_admin = BooleanField(default=True)
    website = URLField(default="http://google.com/")
    updated_at = DateTimeField(required=True,
                               auto_now_on_insert=True,
                               auto_now_on_update=True)
    embedded = EmbeddedDocumentField(EmbeddedDocument,
                                     db_field="embedded_document")
    nullable = EmbeddedDocumentField(EmbeddedDocument,
                                     db_field="nullable_embedded_document")
    numbers = ListField(IntField())

    def __repr__(self):
        return "%s %s <%s>" % (self.first_name, self.last_name, self.email)
Example #18
0
 class Child(Document):
     __collection__ = "NotOperatorTest"
     num = IntField()
Example #19
0
 class SizeDocument(Document):
     items = ListField(IntField())
     item_size = IntField(default=0,
                          on_save=lambda doc, creating: len(doc.items))
Example #20
0
 def test_create_int_field(self):
     field = IntField(db_field="test", min_value=10, max_value=200)
     expect(field.db_field).to_equal("test")
     expect(field.min_value).to_equal(10)
     expect(field.max_value).to_equal(200)
Example #21
0
class City(Document):
    __collection__ = "AggregationCity"

    city = StringField()
    state = StringField()
    pop = IntField()
Example #22
0
 class Test(Document):
     __collection__ = "LesserThanOrEqual"
     test = IntField()
Example #23
0
 class Child(Document):
     __collection__ = "MultipleOperatorsTest"
     num = IntField()
Example #24
0
    def test_is_empty(self):
        field = IntField()

        expect(field.is_empty(None)).to_be_true()
Example #25
0
 class Test2(Document):
     __collection__ = "EmbeddedExistsTest"
     test = IntField()
Example #26
0
 class TestEmbedded(Document):
     __collection__ = "TestEmbedded"
     num = IntField()
Example #27
0
 class Child(Document):
     __collection__ = "EmbeddedIsNullTest"
     num = IntField()
Example #28
0
 class Test(Document):
     __collection__ = "GreaterThan"
     test = IntField()
Example #29
0
    def test_validate_enforces_max_value(self):
        field = IntField(max_value=5)

        expect(field.validate(1)).to_be_true()
        expect(field.validate(6)).to_be_false()
        expect(field.validate("1")).to_be_true()
Example #30
0
 class ReferenceFieldClass(Document):
     __collection__ = "TestFindAllReferenceField"
     ref1 = ReferenceField(User)
     num = IntField(default=10)