def test_mapping_of_objects_to_snapshots_via_tree_view( self, create_audit_with_control_and_update_control, control_for_mapper, dynamic_objects, dynamic_relationships, selenium): """Check mapping of objects to Control's snapshots via UI using Unified Mapper functionality (Tree View element's dropdown): - Audits: using auto-mapping in Program's scope; - Assessments: using Audit's scope; - Issues: using auto-mapping in Assessment's with mapped snapshoted object scope. """ audit_with_one_control = create_audit_with_control_and_update_control expected_control = audit_with_one_control[control_for_mapper][ 0].repr_ui() audit = audit_with_one_control["new_audit_rest"][0] existing_obj = dynamic_objects (get_cls_webui_service(objects.get_plural( existing_obj.type))(selenium).map_objs_via_tree_view_item( src_obj=audit, dest_objs=[expected_control])) controls_ui_service = get_cls_webui_service( objects.get_plural(expected_control.type))(selenium) actual_controls_count = controls_ui_service.get_count_objs_from_tab( src_obj=existing_obj) actual_controls = (controls_ui_service.get_list_objs_from_tree_view( src_obj=existing_obj)) assert len([expected_control]) == actual_controls_count # 'actual_controls': created_at, updated_at, custom_attributes (None) self.general_equal_assert([expected_control], actual_controls, *Representation.tree_view_attrs_to_exclude)
def test_snapshot_can_be_unmapped_from_assessment_or_issue( self, create_audit_with_control_and_update_control, dynamic_objects, selenium, dynamic_object_state): """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 control = audit_with_one_control["new_control_rest"][0].repr_ui() audit = audit_with_one_control["new_audit_rest"][0] existing_obj = dynamic_objects existing_obj_name = objects.get_plural(existing_obj.type) (get_cls_webui_service(existing_obj_name)( selenium).map_objs_via_tree_view_item(src_obj=audit, dest_objs=[control])) controls_ui_service = (get_cls_webui_service( objects.get_plural(control.type))(selenium)) (get_cls_rest_service(existing_obj_name)().update_obj( obj=existing_obj, status=dynamic_object_state)) controls_ui_service.unmap_via_info_panel(existing_obj, control) actual_controls_count = controls_ui_service.get_count_objs_from_tab( src_obj=existing_obj) actual_controls = (controls_ui_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 expected_control = audit_with_one_control["new_control_rest"][ 0].repr_ui() audit = audit_with_one_control["new_audit_rest"][0] existing_obj = dynamic_object (get_cls_webui_service(objects.get_plural( existing_obj.type))(selenium).map_objs_via_tree_view_item( src_obj=audit, dest_objs=[expected_control])) controls_ui_service = get_cls_webui_service( objects.get_plural(expected_control.type))(selenium) actual_controls_count = controls_ui_service.get_count_objs_from_tab( src_obj=existing_obj) actual_controls = (controls_ui_service.get_list_objs_from_tree_view( src_obj=existing_obj)) assert len([expected_control]) == actual_controls_count # 'actual_controls': created_at, updated_at, custom_attributes (None) self.general_equal_assert([expected_control], actual_controls, *Representation.tree_view_attrs_to_exclude)
def test_cannot_create_disabled_obj_from_lhn(self, obj_name, soft_assert, selenium): """Tests that 'New object' modal for disabled object cannot be opened from LHN.""" factory.get_cls_webui_service(obj_name)().get_lhn_accordion( obj_name).create_new() webui_facade.soft_assert_no_modals_present(object_modal.BaseObjectModal(), soft_assert) soft_assert.assert_expectations()
def test_availability_mapping_of_objects_to_snapshotable_objs( self, create_audit_with_control_and_update_control, dynamic_objects, selenium): """Check availability mapping of objects to Control's snapshots via UI using Unified Mapper functionality and AddWidget button on Horizontal Nav Bar. Steps: - Get list of available objects from HNB - Get list of available objects from Unified Mapper - Compare their with constant of snapshotable objects """ mapped_audit = create_audit_with_control_and_update_control[ 'new_audit_rest'][0] obj_ui_service = get_cls_webui_service( objects.get_plural(dynamic_objects.type))(selenium) objs_types_from_mapper = ( obj_ui_service.get_objs_available_to_map_via_mapper( src_obj=mapped_audit)) objs_types_from_add_widget = ( obj_ui_service.get_objs_available_to_map_via_add_widget( src_obj=dynamic_objects)) 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_destructive_snapshot_can_be_unmapped_from_assessment_or_issue( self, create_audit_with_control_and_update_control, dynamic_objects, selenium, dynamic_object_state ): """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 control = audit_with_one_control["new_control_rest"][0].repr_ui() audit = audit_with_one_control["new_audit_rest"][0] existing_obj = dynamic_objects existing_obj_name = objects.get_plural(existing_obj.type) (get_cls_webui_service(existing_obj_name)(selenium). map_objs_via_tree_view_item(src_obj=audit, dest_objs=[control])) controls_ui_service = webui_service.ControlsService(selenium) (get_cls_rest_service(existing_obj_name)(). update_obj(obj=existing_obj, status=dynamic_object_state)) controls_ui_service.unmap_via_info_panel(existing_obj, control) actual_controls_count = controls_ui_service.get_count_objs_from_tab( src_obj=existing_obj) actual_controls = (controls_ui_service.get_list_objs_from_tree_view( src_obj=existing_obj)) assert 0 == actual_controls_count assert [] == actual_controls
def test_destructive_asmt_and_issue_mapped_to_origin_control( self, create_audit_with_control_and_update_control, assessment, obj, selenium ): """ Check Assessment, Issue was mapped to origin Control after mapping: - snapshot of Control to Assessment; - Assessment with mapped snapshot of Control to Issue. """ is_issue_flow = obj["issue"] is not None origin_control = create_audit_with_control_and_update_control[ "updated_control"] snapshoted_control = create_audit_with_control_and_update_control[ "control"] expected_obj = ( obj["issue"] if is_issue_flow else obj["assessment"]).repr_ui().update_attrs( status=obj["expected_state"]) ui_mapping_service, src_obj, dest_objs = ( (webui_service.IssuesService(selenium), obj["assessment"], [obj["issue"]]) if is_issue_flow else (webui_service.ControlsService(selenium), expected_obj, [snapshoted_control])) ui_mapping_service.map_objs_via_tree_view( src_obj=src_obj, dest_objs=dest_objs) actual_objs = (get_cls_webui_service( objects.get_plural(expected_obj.type))(selenium). get_list_objs_from_tree_view(src_obj=origin_control)) # 'actual_controls': created_at, updated_at, custom_attributes, audit # assessment_type, modified_by (None) exclude_attrs = (Representation.tree_view_attrs_to_exclude + ("audit", "assessment_type", "modified_by")) if is_issue_flow: exclude_attrs += ("objects_under_assessment", ) self.general_equal_assert([expected_obj], actual_objs, *exclude_attrs)
def test_asmt_and_issue_mapped_to_origin_control( self, create_audit_with_control_and_update_control, dynamic_objects, 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_objects.repr_ui().update_attrs(status=expected_state)) (webui_service.ControlsService(selenium).map_objs_via_tree_view( src_obj=expected_obj, dest_objs=[snapshoted_control])) actual_objs = (get_cls_webui_service( objects.get_plural(expected_obj.type))(selenium). get_list_objs_from_tree_view(src_obj=origin_control)) # 'actual_controls': created_at, updated_at, custom_attributes (None) exclude_attrs = Representation.tree_view_attrs_to_exclude if dynamic_objects.type == entities_factory.EntitiesFactory.obj_issue: exclude_attrs = exclude_attrs + ("objects_under_assessment", ) self.general_equal_assert([expected_obj], actual_objs, *exclude_attrs)
def test_availability_mapping_of_objects_to_snapshotable_objs( self, create_audit_with_control_and_update_control, dynamic_objects, selenium ): """Check availability mapping of objects to Control's snapshots via UI using Unified Mapper functionality and AddWidget button on Horizontal Nav Bar. Steps: - Get list of available objects from HNB - Get list of available objects from Unified Mapper - Compare their with constant of snapshotable objects """ mapped_audit = create_audit_with_control_and_update_control[ 'new_audit_rest'][0] obj_ui_service = get_cls_webui_service( objects.get_plural(dynamic_objects.type))(selenium) objs_types_from_mapper = ( obj_ui_service.get_objs_available_to_map_via_mapper( src_obj=mapped_audit)) objs_types_from_add_widget = ( obj_ui_service.get_objs_available_to_map_via_add_widget( src_obj=dynamic_objects)) 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 assert_objs_diff_corresponds_to_proposal(self, obj, proposal): """Check if objs difference corresponds to the proposal.""" self.open_obj_change_proposals_tab(obj).click_review_apply_btn( proposal) comparison_window = apply_decline_proposal.CompareApplyDeclineModal() comparison_window.modal.wait_until(lambda e: e.exists) obj_name = objects.get_plural(obj.type) service_cls = factory.get_cls_webui_service(obj_name)(self._driver) current_obj = service_cls.build_obj_from_page( comparison_window.curr_version_obj_root_elem.wait_until( lambda e: e.exists)) obj_after_proposal = service_cls.build_obj_from_page( comparison_window.proposal_version_obj_root_elem.wait_until( lambda e: e.exists)) actual_proposal = entities_factory.ProposalsFactory().create() proposal_obj_dict = obj_after_proposal.__dict__ current_obj_dict = current_obj.__dict__ actual_proposal.changes = [] for key in obj_after_proposal.__dict__.keys(): if proposal_obj_dict[key] != current_obj_dict[key]: actual_proposal.changes.append({ "obj_attr_type": key.title(), "cur_value": current_obj_dict[key], "proposed_value": proposal_obj_dict[key] }) actual_proposal.author = comparison_window.get_proposal_version_author( ) actual_proposal.datetime = ( comparison_window.get_proposal_version_datetime()) comparison_window.click_cancel_btn() assert actual_proposal == proposal
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] obj_ui_service = get_cls_webui_service( objects.get_plural(dynamic_object.type))(selenium) objs_types_from_mapper = ( obj_ui_service.get_objs_available_to_map_via_mapper( src_obj=mapped_audit)) objs_types_from_add_widget = ( obj_ui_service.get_objs_available_to_map_via_add_widget( src_obj=dynamic_object)) 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_objects, 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_objects.repr_ui().update_attrs( status=expected_state)) (webui_service.ControlsService(selenium).map_objs_via_tree_view( src_obj=expected_obj, dest_objs=[snapshoted_control])) actual_objs = (get_cls_webui_service( objects.get_plural( expected_obj.type))(selenium).get_list_objs_from_tree_view( src_obj=origin_control)) # 'actual_controls': created_at, updated_at, custom_attributes (None) exclude_attrs = Representation.tree_view_attrs_to_exclude if dynamic_objects.type == entities_factory.EntitiesFactory.obj_issue: exclude_attrs = exclude_attrs + ("objects_under_assessment", ) self.general_equal_assert([expected_obj], actual_objs, *exclude_attrs)
def test_asmt_and_issue_mapped_to_origin_control( self, create_audit_with_control_and_update_control, dynamic_objects, dynamic_relationships, expected_state, selenium): """ Check Assessment, Issue was mapped to origin Control after mapping: - snapshot of Control to Assessment; - Assessment with mapped snapshot of Control to Issue. """ is_issue_flow = (isinstance(dynamic_objects, dict) and dynamic_objects.get("new_issue_rest") is not None) 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_objects.get("new_issue_rest") if is_issue_flow else dynamic_objects).repr_ui().update_attrs( status=expected_state) ui_mapping_service, src_obj, dest_objs = ( (webui_service.IssuesService(selenium), dynamic_objects.get("new_assessment_rest"), [dynamic_objects.get("new_issue_rest")]) if is_issue_flow else (webui_service.ControlsService(selenium), expected_obj, [snapshoted_control])) ui_mapping_service.map_objs_via_tree_view(src_obj=src_obj, dest_objs=dest_objs) actual_objs = (get_cls_webui_service( objects.get_plural( expected_obj.type))(selenium).get_list_objs_from_tree_view( src_obj=origin_control)) # 'actual_controls': created_at, updated_at, custom_attributes (None) exclude_attrs = Representation.tree_view_attrs_to_exclude if is_issue_flow: exclude_attrs += ("objects_under_assessment", ) self.general_equal_assert([expected_obj], actual_objs, *exclude_attrs)
def assert_objs_diff_corresponds_to_proposal(self, obj, proposal): """Check if objs difference corresponds to the proposal.""" self.open_obj_change_proposals_tab(obj).click_review_apply_btn(proposal) comparison_window = apply_decline_proposal.CompareApplyDeclineModal() comparison_window.modal.wait_until(lambda e: e.exists) obj_name = objects.get_plural(obj.type) service_cls = factory.get_cls_webui_service(obj_name)(self._driver) current_obj = service_cls.build_obj_from_page( comparison_window.curr_version_obj_root_elem.wait_until( lambda e: e.exists)) obj_after_proposal = service_cls.build_obj_from_page( comparison_window.proposal_version_obj_root_elem.wait_until( lambda e: e.exists)) actual_proposal = entities_factory.ProposalsFactory().create() proposal_obj_dict = obj_after_proposal.__dict__ current_obj_dict = current_obj.__dict__ actual_proposal.changes = [] for key in obj_after_proposal.__dict__.keys(): if proposal_obj_dict[key] != current_obj_dict[key]: actual_proposal.changes.append( {"obj_attr_type": key.title(), "cur_value": current_obj_dict[key], "proposed_value": proposal_obj_dict[key]}) actual_proposal.author = comparison_window.get_proposal_version_author() actual_proposal.datetime = ( comparison_window.get_proposal_version_datetime()) comparison_window.click_cancel_btn() assert actual_proposal == proposal
def opened_obj(self, obj, proposal_email): """Build obj from page after clicking on the Open btn in the proposal notification email.""" proposal_digest.ProposalDigest( self._driver).click_proposal_email_open_btn(proposal_email) obj_name = objects.get_plural(obj.type) service_cls = factory.get_cls_webui_service(obj_name)(self._driver) return service_cls.build_obj_from_page()
def opened_obj(self, obj, proposal_email): """Build obj from page after clicking on the Open btn in the proposal notification email.""" fast_emails_digest.FastEmailsDigest( self._driver).click_proposal_email_open_btn(proposal_email) obj_name = objects.get_plural(obj.type) service_cls = factory.get_cls_webui_service(obj_name)(self._driver) return service_cls.build_obj_from_page()
def test_deprecated_obj_review_buttons(self, control, soft_assert, selenium): """Check that buttons 'Mark Reviewed' and 'Request Review' are not displayed at Control Info page.""" info_page = factory.get_cls_webui_service(objects.get_plural( control.type))().open_info_page_of_obj(control) soft_assert.expect(not info_page.mark_reviewed_btn.exists, "There should be no 'Mark Reviewed' button.") soft_assert.expect(not info_page.request_review_btn.exists, "There should be no 'Request Review button.") soft_assert.assert_expectations()
def export_objects(path_to_export_dir, obj_type, src_obj=None, is_versions_widget=False): """Opens generic widget of objects or mapped objects and exports objects to test's temporary directory as CSV file. Returns: list of objects from CSV file in test's temporary directory 'path_to_export_dir'.""" ui_service = factory.get_cls_webui_service( objects.get_plural(singular=obj_type, title=True))(is_versions_widget) widget = (ui_service.open_widget_of_mapped_objs(src_obj) if src_obj else ui_service.open_obj_dashboard_tab()) return ui_service.exported_objs_via_tree_view(path_to_export_dir, widget)
def soft_assert_cannot_add_comment(soft_assert, obj): """Performs soft assert that comment input field is not displayed when 'Add Comment' button is clicked.""" info_page = factory.get_cls_webui_service(objects.get_plural( obj.type))().open_info_page_of_obj(obj) info_page.comments_panel.click_add_button() # wait until new tab contains info page url _, new_tab = browsers.get_browser().windows() test_utils.wait_for(lambda: new_tab.url.endswith(url.Widget.INFO)) soft_assert.expect(not info_page.comments_panel.comment_input.exists, "There should be no input field in comments panel.")
def soft_assert_role_cannot_be_edited(soft_assert, obj, role): """Performs soft assert that click on role's pencil icon doesn't open an input field.""" info_widget = factory.get_cls_webui_service( objects.get_plural(obj.type))().open_info_page_of_obj(obj) role_field_element = getattr(info_widget, role) role_field_element.inline_edit.open() # wait until new tab contains info page url _, new_tab = browsers.get_browser().windows() test_utils.wait_for(lambda: new_tab.url.endswith(url.Widget.INFO)) soft_assert.expect(not role_field_element.add_person_text_field.exists, "There should be no input field.")
def test_user_cannot_update_custom_attribute(self, obj, selenium, soft_assert): """Tests that user cannot update custom attribute.""" cad = rest_facade.create_gcad( definition_type=obj.type.lower(), attribute_type=element.AdminWidgetCustomAttributes.RICH_TEXT) soft_assert.expect( not factory.get_cls_webui_service(objects.get_plural( obj.type))().has_gca_inline_edit(obj, ca_title=cad.title), "GCA field should not be editable.") soft_assert.expect(webui_facade.are_tabs_urls_equal(), "Tabs urls should be equal.") soft_assert.assert_expectations()
def create_proposal(self, obj): """Create a proposal for an obj.""" obj_info_page = factory.get_cls_webui_service(objects.get_plural( obj.type))(self._driver).open_info_page_of_obj(obj) obj_info_page.click_propose_changes() proposal_factory = entities_factory.ProposalsFactory() proposal = proposal_factory.create() proposed_description = proposal_factory.generate_string("Proposal") proposal_modal = object_modal.BaseObjectModal(self._driver) proposal_modal.set_description(proposed_description) proposal_modal.click_propose() proposal.changes = [{"obj_attr_type": "Description", "cur_value": obj.description, "proposed_value": proposed_description}] return proposal
def create_proposal(self, obj): """Create a proposal for an obj.""" obj_info_page = factory.get_cls_webui_service(objects.get_plural( obj.type))(self._driver).open_info_page_of_obj(obj) obj_info_page.click_propose_changes() proposal_factory = entities_factory.ProposalsFactory() proposal = proposal_factory.create() proposed_description = proposal_factory.generate_string("Proposal") proposal_modal = object_modal.BaseObjectModal(self._driver) proposal_modal.set_description(proposed_description) proposal_modal.click_propose() proposal.changes = [{"obj_attr_type": "Description", "cur_value": obj.description, "proposed_value": proposed_description}] return proposal
def soft_assert_cannot_view_version_history(obj, soft_assert, selenium): """Performs soft assertion that user cannot view Version History for disabled object.""" info_page = factory.get_cls_webui_service(objects.get_plural( obj.type))(selenium).open_info_page_of_obj(obj) info_page.click_version_history() soft_assert.expect(are_tabs_urls_equal(), "Tabs urls should be equal.") soft_assert.expect( info_page.version_history_tab_or_link_name not in info_page.tabs.tab_names, "'Version History' tab should not be displayed.") for tab_num, tab in enumerate(browsers.get_browser().windows(), start=1): tab.use() soft_assert.expect( not version_history.VersionHistory().is_version_history_displayed(), "Version history should not be displayed in browser tab number {}.". format(tab_num))
def test_destructive_mapping_of_objects_to_snapshots( self, create_audit_with_control_and_update_control, is_via_tw_map_btn_not_item, expected_snapshoted_control, dynamic_objects, dynamic_relationships, selenium): """Check mapping of objects to Control's snapshots via UI using Unified Mapper functionality (Tree View's 'MAP' button and item): - Assessments: using Audit's scope; - Issues: using auto-mapping in Assessment's with mapped snapshoted object scope. """ audit_with_one_control = create_audit_with_control_and_update_control is_issue_flow = (isinstance(dynamic_objects, dict) and dynamic_objects.get("new_issue_rest") is not None) expected_control = ( audit_with_one_control[expected_snapshoted_control][0].repr_ui()) source_obj_for_map, destination_obj_for_map = ( (dynamic_objects.get("new_assessment_rest"), dynamic_objects.get("new_issue_rest")) if is_issue_flow else (dynamic_objects, expected_control)) obj_for_map = (destination_obj_for_map if is_via_tw_map_btn_not_item else source_obj_for_map) objs_ui_service = (get_cls_webui_service( objects.get_plural(obj_for_map.type))(selenium)) ui_action = ("map_objs_via_tree_view" if is_via_tw_map_btn_not_item else "map_objs_via_tree_view_item") getattr(objs_ui_service, ui_action)( src_obj=(source_obj_for_map if is_via_tw_map_btn_not_item else audit_with_one_control["new_audit_rest"][0]), dest_objs=[destination_obj_for_map]) source_obj_for_controls = (dynamic_objects.get("new_issue_rest") if is_issue_flow else dynamic_objects) # check snapshoted Controls controls_ui_service = webui_service.ControlsService( selenium, is_versions_widget=is_issue_flow) self.get_controls_and_general_assert(controls_ui_service, expected_control, source_obj_for_controls) # check original Controls when Issue is source object if is_issue_flow: expected_control = ( audit_with_one_control["update_control_rest"][0].repr_ui()) controls_ui_service = webui_service.ControlsService(selenium) self.get_controls_and_general_assert(controls_ui_service, expected_control, source_obj_for_controls)
def test_availability_mapping_of_objects_via_mapper_and_add_widget( self, create_audit_with_control_and_update_control, dynamic_objects, dynamic_relationships, selenium ): """Check availability mapping of objects to Assessment and Issue via UI using Unified Mapper functionality and AddWidget button on Horizontal Nav Bar. Steps: - Get list of available objects from Unified Mapper; - Get list of available objects from HNB; - Compare their with constant of expected objects accordingly. """ expected_objs_names_from_mapper = ( objects.ALL_SNAPSHOTABLE_OBJS + (objects.ISSUES, )) if dynamic_objects.type == objects.get_obj_type(objects.ISSUES): expected_objs_names_from_mapper = expected_objs_names_from_mapper + ( objects.PROGRAMS, objects.PROJECTS, objects.DOCUMENTS) expected_objs_names_from_add_widget = expected_objs_names_from_mapper expected_objs_types_from_mapper = sorted( objects.get_normal_form(obj_name) for obj_name in expected_objs_names_from_mapper) expected_objs_types_from_add_widget = sorted( objects.get_normal_form(obj_name) for obj_name in expected_objs_names_from_add_widget) mapped_audit = create_audit_with_control_and_update_control[ "new_audit_rest"][0] obj_ui_service = get_cls_webui_service( objects.get_plural(dynamic_objects.type))(selenium) actual_objs_types_from_mapper = ( obj_ui_service.get_objs_available_to_map_via_mapper( src_obj=mapped_audit)) actual_objs_types_from_add_widget = ( obj_ui_service.get_objs_available_to_map_via_add_widget( src_obj=dynamic_objects)) assert (expected_objs_types_from_mapper == actual_objs_types_from_mapper), ( messages.AssertionMessages.format_err_msg_equal( expected_objs_types_from_mapper, actual_objs_types_from_mapper)) assert (expected_objs_types_from_add_widget == actual_objs_types_from_add_widget), ( messages.AssertionMessages.format_err_msg_equal( expected_objs_types_from_add_widget, actual_objs_types_from_add_widget))
def test_availability_mapping_of_objects_via_mapper_and_add_widget( self, create_audit_with_control_and_update_control, dynamic_objects, dynamic_relationships, selenium ): """Check availability mapping of objects to Assessment and Issue via UI using Unified Mapper functionality and AddWidget button on Horizontal Nav Bar. Steps: - Get list of available objects from Unified Mapper; - Get list of available objects from HNB; - Compare their with constant of expected objects accordingly. """ expected_objs_names_from_mapper = ( objects.ALL_SNAPSHOTABLE_OBJS + (objects.ISSUES, )) if dynamic_objects.type == objects.get_obj_type(objects.ISSUES): expected_objs_names_from_mapper = expected_objs_names_from_mapper + ( objects.PROGRAMS, objects.PROJECTS, objects.DOCUMENTS) expected_objs_names_from_add_widget = expected_objs_names_from_mapper expected_objs_types_from_mapper = sorted( objects.get_normal_form(obj_name) for obj_name in expected_objs_names_from_mapper) expected_objs_types_from_add_widget = sorted( objects.get_normal_form(obj_name) for obj_name in expected_objs_names_from_add_widget) mapped_audit = create_audit_with_control_and_update_control[ "new_audit_rest"][0] obj_ui_service = get_cls_webui_service( objects.get_plural(dynamic_objects.type))(selenium) actual_objs_types_from_mapper = ( obj_ui_service.get_objs_available_to_map_via_mapper( src_obj=mapped_audit)) actual_objs_types_from_add_widget = ( obj_ui_service.get_objs_available_to_map_via_add_widget( src_obj=dynamic_objects)) assert (expected_objs_types_from_mapper == actual_objs_types_from_mapper), ( messages.AssertionMessages.format_err_msg_equal( expected_objs_types_from_mapper, actual_objs_types_from_mapper)) assert (expected_objs_types_from_add_widget == actual_objs_types_from_add_widget), ( messages.AssertionMessages.format_err_msg_equal( expected_objs_types_from_add_widget, actual_objs_types_from_add_widget))
def test_destructive_mapping_of_objects_to_snapshots( self, create_audit_with_control_and_update_control, is_via_tw_map_btn_not_item, expected_snapshoted_control, dynamic_objects, dynamic_relationships, selenium ): """Check mapping of objects to Control's snapshots via UI using Unified Mapper functionality (Tree View's 'MAP' button and item): - Assessments: using Audit's scope; - Issues: using auto-mapping in Assessment's with mapped snapshoted object scope. """ audit_with_one_control = create_audit_with_control_and_update_control is_issue_flow = (isinstance(dynamic_objects, dict) and dynamic_objects.get("new_issue_rest") is not None) expected_control = ( audit_with_one_control[expected_snapshoted_control][0].repr_ui()) source_obj_for_map, destination_obj_for_map = ( (dynamic_objects.get("new_assessment_rest"), dynamic_objects.get("new_issue_rest")) if is_issue_flow else (dynamic_objects, expected_control)) obj_for_map = (destination_obj_for_map if is_via_tw_map_btn_not_item else source_obj_for_map) objs_ui_service = ( get_cls_webui_service(objects.get_plural(obj_for_map.type))(selenium)) ui_action = ("map_objs_via_tree_view" if is_via_tw_map_btn_not_item else "map_objs_via_tree_view_item") getattr(objs_ui_service, ui_action)( src_obj=(source_obj_for_map if is_via_tw_map_btn_not_item else audit_with_one_control["new_audit_rest"][0]), dest_objs=[destination_obj_for_map]) source_obj_for_controls = (dynamic_objects.get("new_issue_rest") if is_issue_flow else dynamic_objects) # check snapshoted Controls controls_ui_service = webui_service.ControlsService( selenium, is_versions_widget=is_issue_flow) self.get_controls_and_general_assert( controls_ui_service, expected_control, source_obj_for_controls) # check original Controls when Issue is source object if is_issue_flow: expected_control = ( audit_with_one_control["update_control_rest"][0].repr_ui()) controls_ui_service = webui_service.ControlsService(selenium) self.get_controls_and_general_assert( controls_ui_service, expected_control, source_obj_for_controls)
def test_destructive_asmt_and_issue_mapped_to_origin_control( self, create_audit_with_control_and_update_control, dynamic_objects, dynamic_relationships, expected_state, selenium ): """ Check Assessment, Issue was mapped to origin Control after mapping: - snapshot of Control to Assessment; - Assessment with mapped snapshot of Control to Issue. """ is_issue_flow = (isinstance(dynamic_objects, dict) and dynamic_objects.get("new_issue_rest") is not None) 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_objects.get("new_issue_rest") if is_issue_flow else dynamic_objects).repr_ui().update_attrs(status=expected_state) ui_mapping_service, src_obj, dest_objs = ( (webui_service.IssuesService(selenium), dynamic_objects.get("new_assessment_rest"), [dynamic_objects.get("new_issue_rest")]) if is_issue_flow else (webui_service.ControlsService(selenium), expected_obj, [snapshoted_control])) ui_mapping_service.map_objs_via_tree_view( src_obj=src_obj, dest_objs=dest_objs) actual_objs = (get_cls_webui_service( objects.get_plural(expected_obj.type))(selenium). get_list_objs_from_tree_view(src_obj=origin_control)) # 'actual_controls': created_at, updated_at, custom_attributes, audit # assessment_type, modified_by (None) exclude_attrs = (Representation.tree_view_attrs_to_exclude + ("audit", "assessment_type", "modified_by")) if is_issue_flow: exclude_attrs += ("objects_under_assessment", ) self.general_equal_assert([expected_obj], actual_objs, *exclude_attrs)
def open_obj_change_proposals_tab(self, obj): """Open change proposals tab of an obj.""" obj_info_page = factory.get_cls_webui_service(objects.get_plural( obj.type))(self._driver).open_info_page_of_obj(obj) return obj_info_page.related_proposals()
def open_obj_change_proposals_tab(self, obj): """Open change proposals tab of an obj.""" obj_info_page = factory.get_cls_webui_service( objects.get_plural(obj.type))( self._driver).open_info_page_of_obj(obj) return obj_info_page.related_proposals()
def _related_asmts_of_obj(obj, selenium): """Return related assessments of obj (Control or Objective)""" return factory.get_cls_webui_service(objects.get_plural( obj.type))(selenium).get_obj_related_asmts_titles(obj)
def _related_asmts_of_obj(obj, selenium): """Return related assessments of obj (Control or Objective)""" return factory.get_cls_webui_service(objects.get_plural( obj.type))(selenium).get_obj_related_asmts_titles(obj)