本文整理汇总了Python中integration.ggrc.TestCase._create_snapshots方法的典型用法代码示例。如果您正苦于以下问题:Python TestCase._create_snapshots方法的具体用法?Python TestCase._create_snapshots怎么用?Python TestCase._create_snapshots使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类integration.ggrc.TestCase
的用法示例。
在下文中一共展示了TestCase._create_snapshots方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from integration.ggrc import TestCase [as 别名]
# 或者: from integration.ggrc.TestCase import _create_snapshots [as 别名]
def __init__(self, user_id, acr, parent=None):
"""Set up objects for Snapshot permission tests.
Args:
user_id: Id of user under which all operations will be run.
acr: Instance of ACR that should be assigned for tested user.
parent: Model name in scope of which objects should be set up.
"""
self.setup_program_scope(user_id, acr)
control = factories.ControlFactory()
# pylint: disable=protected-access
snapshot = TestCase._create_snapshots(self.audit, [control])[0]
factories.RelationshipFactory(source=snapshot, destination=self.audit)
factories.RelationshipFactory(source=control, destination=self.program)
if parent == "Assessment":
factories.RelationshipFactory(
source=snapshot, destination=self.assessment
)
self.control_id = control.id
self.snapshot_id = snapshot.id
self.user_id = user_id
self.api = Api()
self.objgen = generator.ObjectGenerator()
self.objgen.api = self.api
if user_id:
user = all_models.Person.query.get(user_id)
self.api.set_user(user)
示例2: generate
# 需要导入模块: from integration.ggrc import TestCase [as 别名]
# 或者: from integration.ggrc.TestCase import _create_snapshots [as 别名]
def generate(self):
"""Generate new Assessment object."""
with factories.single_commit():
control = factories.ControlFactory()
template_id = factories.AssessmentTemplateFactory().id
audit = all_models.Audit.query.get(self.audit_id)
# pylint: disable=protected-access
snapshot = TestCase._create_snapshots(audit, [control])[0]
snapshot_id = snapshot.id
factories.RelationshipFactory(source=snapshot, destination=audit)
responses = []
asmnt_data = {
"assessment": {
"_generated": True,
"audit": {
"id": self.audit_id,
"type": "Audit"
},
"object": {
"id": snapshot_id,
"type": "Snapshot"
},
"context": None,
"title": "New assessment",
}
}
responses.append(self.api.post(all_models.Assessment, asmnt_data))
asmnt_data["assessment"]["template"] = {
"id": template_id,
"type": "AssessmentTemplate"
}
responses.append(self.api.post(all_models.Assessment, asmnt_data))
return responses
示例3: create_reindexed_snapshots
# 需要导入模块: from integration.ggrc import TestCase [as 别名]
# 或者: from integration.ggrc.TestCase import _create_snapshots [as 别名]
def create_reindexed_snapshots(audit_id, objects):
"""Create snapshots for list of provided objects and reindex them"""
# pylint: disable=protected-access
snapshottable_objects = [o for o in objects if o.type in Types.all]
audit = all_models.Audit.query.get(audit_id)
snapshots = TestCase._create_snapshots(audit, snapshottable_objects)
reindex_snapshots_ids = [snap.id for snap in snapshots]
get_indexer().delete_records_by_ids("Snapshot",
reindex_snapshots_ids,
commit=False)
reindex_snapshots(reindex_snapshots_ids)
示例4: map_snapshot
# 需要导入模块: from integration.ggrc import TestCase [as 别名]
# 或者: from integration.ggrc.TestCase import _create_snapshots [as 别名]
def map_snapshot(self):
"""Map snapshot to assessment."""
audit = all_models.Audit.query.get(self.audit_id)
assessment = all_models.Assessment.query.get(self.assessment_id)
control = factories.ControlFactory()
# pylint: disable=protected-access
snapshot = TestCase._create_snapshots(audit, [control])[0]
factories.RelationshipFactory(source=snapshot, destination=audit)
return self.objgen.generate_relationship(
source=assessment,
destination=snapshot,
)[0]
示例5: related_assessments
# 需要导入模块: from integration.ggrc import TestCase [as 别名]
# 或者: from integration.ggrc.TestCase import _create_snapshots [as 别名]
def related_assessments(self):
"""Get related Assessments for existing object."""
audit = all_models.Audit.query.get(self.audit_id)
assessment = all_models.Assessment.query.get(self.assessment_id)
with factories.single_commit():
control = factories.ControlFactory()
# pylint: disable=protected-access
snapshot = TestCase._create_snapshots(audit, [control])[0]
factories.RelationshipFactory(source=audit, destination=snapshot)
factories.RelationshipFactory(source=assessment, destination=snapshot)
assessment2 = factories.AssessmentFactory(
assessment_type=assessment.assessment_type
)
factories.RelationshipFactory(source=assessment2, destination=snapshot)
return self.api.client.get(
"/api/related_assessments?object_id={}&object_type=Assessment".format(
self.assessment_id
)
)