Пример #1
0
def create_asmt_from_template(audit, asmt_template, obj_to_map):
    """Create an assessment from template"""
    snapshots = [
        Representation.convert_repr_to_snapshot(objs=obj_to_map,
                                                parent_obj=audit)
    ]
    return rest_service.AssessmentsFromTemplateService().create_assessments(
        audit=audit, template=asmt_template, snapshots=snapshots)[0]
Пример #2
0
def create_asmt_from_template_rest(audit, control, asmt_template):
    """Create new Assessment based on Assessment Template via REST API.
  Return: lib.entities.entity.AssessmentEntity
  """
    control_snapshots = [
        Representation.convert_repr_to_snapshot(objs=control, parent_obj=audit)
    ]
    assessments_service = rest_service.AssessmentsFromTemplateService()
    assessments = assessments_service.create_assessments(
        audit=audit,
        template=asmt_template,
        control_snapshots=control_snapshots)
    return assessments[0]
Пример #3
0
def get_fixture_from_dict_fixtures(fixture):
  """Get value of fixture by key (fixture name) from dictionary of
  executed fixtures."""
  global dict_executed_fixtures
  # extend executed fixtures using exist fixture in snapshot representation
  if fixture.endswith("_snapshot"):
    origin_obj = get_fixture_from_dict_fixtures(
        fixture.replace("_snapshot", ""))
    parent_obj = get_fixture_from_dict_fixtures("new_audit_rest")[0]
    dict_executed_fixtures.update(
        {fixture: Representation.convert_repr_to_snapshot(
            objs=origin_obj, parent_obj=parent_obj)})
  return {k: v for k, v in dict_executed_fixtures.iteritems()
          if k == fixture}[fixture]
Пример #4
0
def get_fixture_from_dict_fixtures(fixture):
  """Get value of fixture by key (fixture name) from dictionary of
  executed fixtures."""
  global dict_executed_fixtures
  # extend executed fixtures using exist fixture in snapshot representation
  if fixture.endswith("_snapshot"):
    origin_obj = get_fixture_from_dict_fixtures(
        fixture.replace("_snapshot", ""))
    parent_obj = get_fixture_from_dict_fixtures("new_audit_rest")[0]
    dict_executed_fixtures.update(
        {fixture: Representation.convert_repr_to_snapshot(
            objs=origin_obj, parent_obj=parent_obj)})
  return {k: v for k, v in dict_executed_fixtures.iteritems()
          if k == fixture}[fixture]
Пример #5
0
def create_asmt_from_template_rest(
    audit, control, asmt_template
):
  """Create new Assessment based on Assessment Template via REST API.
  Return: lib.entities.entity.AssessmentEntity
  """
  control_snapshots = [Representation.convert_repr_to_snapshot(
      objs=control, parent_obj=audit)]
  assessments_service = rest_service.AssessmentsFromTemplateService()
  assessments = assessments_service.create_assessments(
      audit=audit,
      template=asmt_template,
      control_snapshots=control_snapshots
  )
  return assessments[0]
Пример #6
0
def convert_obj_to_snapshot(audit, obj):
    """Convert object to snapshot."""
    return Representation.convert_repr_to_snapshot(obj=obj, parent_obj=audit)
Пример #7
0
def convert_cntrl_to_snapshot(audit, obj):
  """Convert control to snapshot."""
  return Representation.convert_repr_to_snapshot(
      objs=obj, parent_obj=audit)
Пример #8
0
def convert_obj_to_snapshot(audit, obj):
  """Convert object to snapshot."""
  return Representation.convert_repr_to_snapshot(
      obj=obj, parent_obj=audit)