def test_from_son(self): field = ReferenceField(db_field="test", reference_document_type=User) data = ObjectId("123456789012123456789012") result = field.from_son(data) expect(result).to_equal(ObjectId("123456789012123456789012"))
def test_to_son(self): field = ReferenceField(db_field="test", reference_document_type=User) u = User(name="test") u._id = ObjectId("123456789012123456789012") result = field.to_son(u) expect(str(result)).to_equal(str(u._id))
class PenetrationTestDataNote(MyDocument): """ 渗透测试详情 """ __collection__ = "penetration_test_data_note" penetration_id = StringField(max_length=1024) ip = StringField(max_length=1024) details = ListField(ReferenceField(UnitPenetrationTest)) # SSHRootEmptyPassword = StringField(max_length=1024) # RedisEmptyPassword = StringField(max_length=1024) # MongoEmptyPassword = StringField(max_length=1024) organization = ReferenceField( reference_document_type=Organization) # 数据所属的组织
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)
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) # 数据所属的组织
def test_cant_create_reference_field_of_the_wrong_type(self): try: ReferenceField(reference_document_type=10).validate(None) except ValueError: err = sys.exc_info()[1] expected = "The field 'reference_document_type' argument must be a subclass of Document, not '10'." expect(err).to_have_an_error_message_of(expected) else: assert False, "Should not have gotten this far"
class OrgResourceGroupRelation(OrgUserDataDocument): """ 组织和资源组的关系,不同的资源组有不同的限额 """ __collection__ = 'org_resource_grp_rel' __lazy__ = False r_grp = ReferenceField(reference_document_type=ResourceGroup) rg_name = StringField() # 冗余
class OrgResourceCnt(OrgUserDataDocument): """ 当前组织使用资源的情况 """ __collection__ = 'org_resource_cnt' __lazy__ = False resource = ReferenceField(reference_document_type=ProductResource) r_name = StringField() # 冗余 cnt = IntField()
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) # 数据所属的组织
class ResourceGroupLimit(OrgUserDataDocument): """ 每个账号的相应的资源的限额 """ __collection__ = 'resource_group_limit' __lazy__ = False resource = ReferenceField(reference_document_type=ProductResource) r_name = StringField() # 冗余 ,资源名称 limit = IntField() # 目录创建的数目
class ProxyipTestData(MyDocument): """ 爆破测试 """ __collection__ = "proxyip_test_data" remoteip = StringField(max_length=1024) originalip = StringField(max_length=1024) proxyip = StringField(max_length=1024) organization = ReferenceField( reference_document_type=Organization) # 数据所属的组织
class ServiceStatus(MyDocument): """ 服务器开放的服务状态 """ __collection__ = "service_status" info_asset = ReferenceField(reference_document_type=InfoAsset) # 所属资产,信息资产 port = IntField() # 端口号 protocol = StringField() # 协议名称 status = StringField() # 状态 version = StringField # 版本
class ApiTestDataNote(MyDocument): """ api测试详细数据,只记录失败和错误---因为性能问题,取消使用 2016-09-30 """ __collection__ = "api_test_data_note" apitestdata_id = StringField(max_length=1024) test_case = StringField(max_length=1024) # 出错测试用例 explain = StringField(max_length=1024) # 目的 status = StringField(max_length=1024) # 测试状态,失败或者错误 note = StringField() # 详细记录 organization = ReferenceField( reference_document_type=Organization) # 数据所属的组织
class LimitTestDataNote(MyDocument): """ api测试详细数据,只记录失败和错误(作废-2016-11-23) """ __collection__ = "limit_test_data_note" limittestdata_id = StringField(max_length=1024) test_case = StringField(max_length=1024) # 出错测试用例 explain = StringField(max_length=1024) # 目的 status = StringField(max_length=1024) # 测试状态,失败或者错误 note = StringField() # 详细记录 organization = ReferenceField( reference_document_type=Organization) # 数据所属的组织
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) # 数据所属的组织
class ProjectDataDocument(OrgDataBaseDocument, MyDocument): """ 项目数据 """ # 数据归属 project = ReferenceField(reference_document_type=Project) # 测试数据所属的项目 project_name = StringField() # 项目名称,冗余 async def set_project_tag(self, project): """ 打上项目标记 :type project:Project :return: """ organization = project.organization self.project = project self.project_name = project.project_name self.organization = organization self.org_name = organization.name
class ReferenceFieldClass(Document): __collection__ = "TestFindAllReferenceField" ref1 = ReferenceField(User) num = IntField(default=10)
class Test(Document): __collection__ = "EmbeddedExistsTestParent" test = ReferenceField(Test2)
class Parent(Document): __collection__ = "EmbeddedIsNullTestParent" child = ReferenceField(Child)
class ReferenceFieldClass(Document): ref1 = ReferenceField(User) ref2 = ReferenceField(User) ref3 = ReferenceField(User)
class Comment(Document): text = StringField(required=True) user = ReferenceField(User, required=True)
def test_create_reference_field(self): field = ReferenceField(db_field="test", reference_document_type=User) expect(field.db_field).to_equal("test") expect(field.reference_type).to_equal(User)
def test_create_reference_field_with_string_class(self): field = ReferenceField(db_field="test", reference_document_type="tests.fields.test_reference_field.User") expect(field.reference_type).to_equal(User)
class CommentNotLazy(Document): __lazy__ = False text = StringField(required=True) user = ReferenceField(User, required=True)
class Base(Document): __collection__ = 'base' __lazy__ = False list_val = ListField(ReferenceField(reference_document_type=Ref))