def test_mapping_of_assessments_and_issues_to_snapshots_via_tree_view( self, create_audit_with_control_and_update_control, dynamic_object, selenium): """Check mapping of assessments or issues to snapshot of control via tree view. Test parameters: "Checking assessment" "Checking issue" """ audit_with_one_control = create_audit_with_control_and_update_control # due to 'actual_control.custom_attributes = {None: None}' expected_control = (audit_with_one_control["new_control_rest"] [0].repr_ui().update_attrs( custom_attributes={None: None})) audit = audit_with_one_control["new_audit_rest"][0] existing_obj = dynamic_object[0] existing_obj_service = get_ui_service(existing_obj.type)(selenium) (existing_obj_service.map_objs_via_tree_view_item( src_obj=audit, dest_objs=[expected_control])) controls_service = get_ui_service(expected_control.type)(selenium) actual_controls_count = controls_service.get_count_objs_from_tab( src_obj=existing_obj) actual_controls = (controls_service.get_list_objs_from_tree_view( src_obj=existing_obj)) assert len([expected_control]) == actual_controls_count assert [expected_control ] == actual_controls, (messages.ERR_MSG_FORMAT.format( expected_control, actual_controls))
def test_snapshot_can_be_unmapped_from_assessment_or_issue( self, create_audit_with_control_and_update_control, dynamic_object, selenium): """Check Snapshot can be unmapped from assessment using "Unmap" button on info panel. Test parameters: "Checking assessment" "Checking issue" Steps: - Create assessment - Map snapshoted control with assessment - Unmap snapshot from assessment - Make sure that assessment has no any mapped snapshots """ # pylint: disable=misplaced-comparison-constant audit_with_one_control = create_audit_with_control_and_update_control # due to 'actual_control.custom_attributes = {None: None}' control = (audit_with_one_control["new_control_rest"] [0].repr_ui().update_attrs(custom_attributes={None: None})) audit = audit_with_one_control["new_audit_rest"][0] existing_obj = dynamic_object[0] existing_obj_service = get_ui_service(existing_obj.type)(selenium) (existing_obj_service.map_objs_via_tree_view_item(src_obj=audit, dest_objs=[control])) controls_service = get_ui_service(control.type)(selenium) controls_service.unmap_via_info_panel(existing_obj, control) actual_controls_count = controls_service.get_count_objs_from_tab( src_obj=existing_obj) actual_controls = (controls_service.get_list_objs_from_tree_view( src_obj=existing_obj)) assert 0 == actual_controls_count assert [] == actual_controls
def test_mapping_of_assessments_and_issues_to_snapshots_via_tree_view( self, create_audit_with_control_and_update_control, dynamic_object, selenium ): """Check mapping of assessments or issues to snapshot of control via tree view. Test parameters: "Checking assessment" "Checking issue" """ audit_with_one_control = create_audit_with_control_and_update_control # due to 'actual_control.custom_attributes = {None: None}' expected_control = ( audit_with_one_control["new_control_rest"][0]. repr_ui().update_attrs(custom_attributes={None: None})) audit = audit_with_one_control["new_audit_rest"][0] existing_obj = dynamic_object[0] existing_obj_service = get_ui_service(existing_obj.type)(selenium) (existing_obj_service.map_objs_via_tree_view_item( src_obj=audit, dest_objs=[expected_control])) controls_service = get_ui_service(expected_control.type)(selenium) actual_controls_count = controls_service.get_count_objs_from_tab( src_obj=existing_obj) actual_controls = (controls_service.get_list_objs_from_tree_view( src_obj=existing_obj)) assert len([expected_control]) == actual_controls_count assert [expected_control] == actual_controls, ( messages.ERR_MSG_FORMAT.format(expected_control, actual_controls))
def test_asmts_and_issues_mapping_to_snapshotable_objs( self, create_audit_with_control_and_update_control, dynamic_object, selenium): """Check only snapshotable objs are available to map via UnifiedMapper and AddWidget button on Horizontal Nav Bar. Test parameters: "Checking assessment" "Checking issue" Steps: - Get list of available objs from HNB - Get list of available objs from UnifiedMapper - Compare their with constant of snapshotable objs """ mapped_audit = create_audit_with_control_and_update_control[ 'new_audit_rest'][0] source_obj = (dynamic_object[0].repr_ui().update_attrs( custom_attributes={None: None})) obj_service = get_ui_service(source_obj.type)(selenium) objs_types_from_mapper = ( obj_service.get_objs_available_to_map_via_mapper( src_obj=mapped_audit)) objs_types_from_add_widget = ( obj_service.get_objs_available_to_map_via_add_widget( src_obj=source_obj)) expected_objs_types = sorted( objects.get_normal_form(snap_obj) for snap_obj in objects.ALL_SNAPSHOTABLE_OBJS) assert (expected_objs_types == objs_types_from_mapper == objs_types_from_add_widget)
def test_asmt_and_issue_mapped_to_origin_control( self, create_audit_with_control_and_update_control, dynamic_object, selenium): """ Check Assessment or Issue was mapped to origin control after mapping snapshot of control to Assessment or Issue. Test parameters: - check Assessment - check Issue """ origin_control = create_audit_with_control_and_update_control[ "update_control_rest"][0] snapshoted_control = create_audit_with_control_and_update_control[ "new_control_rest"][0] # due to 'actual_control.custom_attributes = {None: None}' expected_obj = (dynamic_object[0].repr_ui().update_attrs( custom_attributes={None: None})) expected_obj_service = get_ui_service(expected_obj.type)(selenium) (webui_service.ControlsService(selenium).map_objs_via_tree_view( src_obj=expected_obj, dest_objs=[snapshoted_control])) actual_objs = expected_obj_service.get_list_objs_from_tree_view( src_obj=origin_control) assert [ expected_obj ] == actual_objs, (messages.AssertionMessages.format_err_msg_equal( expected_obj, actual_objs))
def test_asmt_and_issue_mapped_to_origin_control( self, create_audit_with_control_and_update_control, dynamic_object, expected_state, selenium): """ Check Assessment or Issue was mapped to origin control after mapping snapshot of control to Assessment or Issue. Test parameters: - check Assessment - check Issue """ origin_control = create_audit_with_control_and_update_control[ "update_control_rest"][0] snapshoted_control = create_audit_with_control_and_update_control[ "new_control_rest"][0] expected_obj = dynamic_object.repr_ui().update_attrs( status=expected_state) expected_obj_service = get_ui_service(expected_obj.type)(selenium) (webui_service.ControlsService(selenium).map_objs_via_tree_view( src_obj=expected_obj, dest_objs=[snapshoted_control])) actual_objs = expected_obj_service.get_list_objs_from_tree_view( src_obj=origin_control) # due to 'actual_obj.custom_attributes = {None: None}' # 'expected_asmt.objects_under_assessment = None' self.general_assert([expected_obj], actual_objs, "custom_attributes" if dynamic_object.type == entities_factory.EntitiesFactory.obj_issue else "objects_under_assessment", "custom_attributes")