当前位置: 首页>>代码示例>>Python>>正文


Python ggrc.TestCase类代码示例

本文整理汇总了Python中integration.ggrc.TestCase的典型用法代码示例。如果您正苦于以下问题:Python TestCase类的具体用法?Python TestCase怎么用?Python TestCase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TestCase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

  def setUp(self):
    """Imports test_csvs/audit_rbac_snapshot_create.csv needed by the tests"""
    TestCase.clear_data()
    self.api = Api()
    self.objgen = integration.ggrc.generator.ObjectGenerator()

    self.csv_files = itertools.cycle([
        "audit_rbac_snapshot_create.csv",
        "audit_rbac_snapshot_update.csv"
    ])

    self._import_file(next(self.csv_files))
    self.people = all_models.Person.eager_query().all()

    self.program = db.session.query(all_models.Program).filter(
        all_models.Program.slug == "PMRBACPROGRAM-1"
    ).one()

    sources = set(r.source for r in self.program.related_sources)
    destinations = set(r.destination
                       for r in self.program.related_destinations)
    related = [obj for obj in sources.union(destinations)
               if not isinstance(obj, all_models.Person)]
    self.related_objects = related

    self.api = Api()
    self.client.get("/login")

    self.audit = self.create_audit()

    self.snapshots = all_models.Snapshot.eager_query().all()

    self.sanity_check()
开发者ID:VinnieJohns,项目名称:ggrc-core,代码行数:33,代码来源:test_audit_snapshot_rbac.py

示例2: setUp

 def setUp(self):
   """Set up test cases for all tests."""
   TestCase.clear_data()
   self._generate_cad()
   response = self._import_file("sorting_with_ca_setup.csv")
   self._check_csv_response(response, {})
   self.client.get("/login")
开发者ID:zidarsk8,项目名称:ggrc-core,代码行数:7,代码来源:test_basic.py

示例3: setUpClass

  def setUpClass(cls):
    """Prepare data needed to run the tests"""
    TestCase.clear_data()
    cls.response = cls._import_file("audit_rbac.csv")

    with app.app_context():
      cls.people = {
          person.name: person
          for person in all_models.Person.eager_query().all()
      }
      created_objects = (
          (all_models.Audit, all_models.Audit.slug == 'AUDIT-1', 'audit'),
          (all_models.Audit,
           all_models.Audit.slug == 'AUDIT-2', 'archived_audit'),
          (all_models.Issue, all_models.Issue.slug == 'PMRBACISSUE-1',
           'issue'),
          (all_models.Issue, all_models.Issue.slug == 'PMRBACISSUE-2',
           'archived_issue'),
          (all_models.Assessment,
           all_models.Assessment.slug == 'PMRBACASSESSMENT-1', 'assessment'),
          (all_models.Assessment,
           all_models.Assessment.slug == 'PMRBACASSESSMENT-2',
           'archived_assessment')
      )
      for obj, cond, name in created_objects:
        setattr(cls, name, obj.eager_query().filter(cond).first())

      revision = all_models.Revision.query.filter(
          all_models.Revision.resource_type == 'Objective').first()
      cls.rev_id = revision.id

      # Create snapshot objects:
      for audit, name in ((cls.audit, 'snapshot'),
                          (cls.archived_audit, 'archived_snapshot')):
        setattr(cls, name, factories.SnapshotFactory(
            child_id=revision.resource_id,
            child_type=revision.resource_type,
            revision=revision,
            parent=audit,
            context=audit.context,
        ))

      # Create asessment template objects:
      for audit, name in ((cls.audit, 'template'),
                          (cls.archived_audit, 'archived_template')):
        template = factories.AssessmentTemplateFactory(
            context=audit.context,
        )
        factories.RelationshipFactory(
            source=audit,
            destination=template,
            context=audit.context
        )
        setattr(cls, name, template)
      # Refresh objects in the session
      for obj in db.session:
        db.session.refresh(obj)
开发者ID:Smotko,项目名称:ggrc-core,代码行数:57,代码来源:test_audit_archiving.py

示例4: setUp

 def setUp(self):
   """Set up test cases for all tests."""
   TestCase.clear_data()
   self._assessment_with_date = None
   self._assessment_with_text = None
   self._generate_special_assessments()
   self._generate_cad()
   self._import_file("sorting_with_ca_setup.csv")
   self.client.get("/login")
开发者ID:VinnieJohns,项目名称:ggrc-core,代码行数:9,代码来源:test_query.py

示例5: setUpClass

 def setUpClass(cls):
   TestCase.clear_data()
   cls.response = cls._import_file("audit_rbac.csv")
   cls.people = all_models.Person.eager_query().all()
   cls.audit = all_models.Audit.eager_query().first()
   sources = set(r.source for r in cls.audit.related_sources)
   destinations = set(r.destination for r in cls.audit.related_destinations)
   related = [obj for obj in sources.union(destinations)
              if not isinstance(obj, all_models.Person)]
   cls.related_objects = related
开发者ID:zidarsk8,项目名称:ggrc-core,代码行数:10,代码来源:test_audit_rbac.py

示例6: setUp

 def setUp(self):
   """Prepare data needed to run the tests"""
   TestCase.clear_data()
   self.api = Api()
   self.client.get("/login")
   self.archived_audit = factories.AuditFactory(
       archived=True
   )
   self.archived_audit.context = factories.ContextFactory(
       name="Audit context",
       related_object=self.archived_audit,
   )
   self.audit = factories.AuditFactory()
   self.assessment = factories.AssessmentFactory()
开发者ID:Smotko,项目名称:ggrc-core,代码行数:14,代码来源:test_audit_archiving.py

示例7: __init__

  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)
开发者ID:egorhm,项目名称:ggrc-core,代码行数:31,代码来源:snapshot.py

示例8: generate

  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
开发者ID:egorhm,项目名称:ggrc-core,代码行数:35,代码来源:assessment.py

示例9: create_reindexed_snapshots

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)
开发者ID:Smotko,项目名称:ggrc-core,代码行数:11,代码来源:helpers.py

示例10: map_snapshot

  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]
开发者ID:egorhm,项目名称:ggrc-core,代码行数:13,代码来源:assessment.py

示例11: related_assessments

  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
        )
    )
开发者ID:egorhm,项目名称:ggrc-core,代码行数:20,代码来源:assessment.py

示例12: setUpClass

 def setUpClass(cls):
   """Set up test cases for all tests."""
   TestCase.clear_data()
   # This imported file could be simplified a bit to speed up testing.
   cls.response = cls._import_file("people_order.csv")
开发者ID:Smotko,项目名称:ggrc-core,代码行数:5,代码来源:test_order.py

示例13: setUpClass

 def setUpClass(cls):
   TestCase.clear_data()
   cls.response = TestCase._import_file("import_comments.csv")
开发者ID:egorhm,项目名称:ggrc-core,代码行数:3,代码来源:test_import_comments.py

示例14: setUpClass

 def setUpClass(cls):
   """Set up test cases for all tests."""
   TestCase.clear_data()
   cls._generate_cad()
   cls.response = cls._import_file("querying_with_unicode.csv")
开发者ID:egorhm,项目名称:ggrc-core,代码行数:5,代码来源:test_basic.py

示例15: setUp

 def setUp(self):
   """Set up test cases for all tests."""
   TestCase.clear_data()
   self._generate_cad()
   self.import_file("sorting_with_ca_setup.csv")
   self.client.get("/login")
开发者ID:egorhm,项目名称:ggrc-core,代码行数:6,代码来源:test_basic.py


注:本文中的integration.ggrc.TestCase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。