Пример #1
0
 def create_audit_and_update_first_of_two_original_controls(
         self, create_audit_and_update_original_control):
     """Create Audit with snapshotable Control and update original Control under
 Program via REST API. After that create second Control and map it to
 Program via REST API.
 Preconditions:
 - Execution and return of fixture
   'create_audit_and_update_original_control'.
 - Second Control created via REST API.
 - Second Control mapped to Program via REST API.
 """
     audit_with_one_control = create_audit_and_update_original_control
     second_control = rest_service.ControlsService().create_objs(count=1)[0]
     rest_service.ObjectsOwnersService().assign_owner_to_objs(
         objs=second_control)
     rest_service.RelationshipsService().map_objs(
         src_obj=audit_with_one_control["program"],
         dest_objs=second_control)
     return {
         "audit": create_audit_and_update_original_control["audit"],
         "program": audit_with_one_control["program"],
         "control": audit_with_one_control["control"],
         "updated_control": audit_with_one_control["updated_control"],
         "second_control": second_control
     }
Пример #2
0
 def map_rest_fixture(fixture):
   """Extract arguments of 'map_rest_fixture' fixture from fixture name,
   find previously created source and destination objects,
   map them via REST API and return result of mapping.
   """
   fixture_params = fixture.replace("map_", "")
   _src_obj, _dest_objs = fixture_params.split("_to_")
   src_obj = _get_fixture_from_dict_fixtures(fixture=_src_obj)[0]
   dest_objs = _get_fixture_from_dict_fixtures(fixture=_dest_objs)
   mapped_objs = rest_service.RelationshipsService().map_objs(
       src_obj=src_obj, dest_objs=dest_objs)
   return mapped_objs
Пример #3
0
def map_objs(src_obj, dest_obj):
  """Map two objects to each other"""

  def _is_external(src_obj, dest_obj):
    """Check if one of objects to map is external."""
    singular_title_external_objs = [
        objects.get_singular(x, title=True) for x in objects.EXTERNAL_OBJECTS]
    objects_list = [src_obj, ]
    dest_ojbect_list = dest_obj if isinstance(dest_obj,
                                              (tuple, list)) else [dest_obj, ]
    objects_list.extend(dest_ojbect_list)
    if [x for x in objects_list if x.type in singular_title_external_objs]:
      return True
    return False

  return rest_service.RelationshipsService().map_objs(
      src_obj=src_obj, dest_objs=dest_obj,
      is_external=_is_external(src_obj, dest_obj))
Пример #4
0
 def test_mapping_objectives_to_control_via_rest(self, new_control_rest,
                                                 dynamic_object,
                                                 dynamic_relationships,
                                                 is_map_again, selenium):
     """Check if Objectives can be mapped to Control via REST."""
     # pylint: disable=too-many-arguments
     expected_status_code = RestClient.STATUS_CODES["OK"]
     dynamic_relationships = string_utils.convert_to_list(
         dynamic_relationships)
     assert all(expected_status_code == relationship.status_code
                for relationship in dynamic_relationships)
     assert ((rest_service.RelationshipsService().map_objs(
         src_obj=new_control_rest, dest_objs=dynamic_object))[0].status_code
             == expected_status_code) if is_map_again else True
     actual_objectives_tab_count = (
         webui_service.ObjectivesService(selenium).get_count_objs_from_tab(
             src_obj=new_control_rest))
     assert (len(string_utils.convert_to_list(dynamic_object)) ==
             actual_objectives_tab_count)
Пример #5
0
def map_objs(src_obj, dest_obj):
    """Map two objects to each other"""
    rest_service.RelationshipsService().map_objs(src_obj=src_obj,
                                                 dest_objs=dest_obj)