Пример #1
0
 def test_bulk_update_audit_objects_to_latest_ver(
         self, create_audit_and_update_first_of_two_original_controls,
         selenium):
     """Check via UI that Audit contains snapshotable Controls that up-to-date
 with their actual states after bulk updated audit objects
 to latest version.
 Preconditions:
 - Execution and return of fixture
   'create_audit_and_update_first_of_two_original_controls'.
 """
     audit_with_two_controls = (
         create_audit_and_update_first_of_two_original_controls)
     audit = audit_with_two_controls["audit"]
     expected_controls = [
         expected_control.repr_ui() for expected_control in [
             audit_with_two_controls["updated_control"],
             audit_with_two_controls["second_control"]
         ]
     ]
     (webui_service.AuditsService(selenium).bulk_update_via_info_page(
         audit_obj=audit))
     controls_ui_service = webui_service.ControlsService(selenium)
     actual_controls_tab_count = controls_ui_service.get_count_objs_from_tab(
         src_obj=audit)
     assert len(expected_controls) == actual_controls_tab_count
     actual_controls = controls_ui_service.get_list_objs_from_tree_view(
         src_obj=audit)
     # 'actual_controls': created_at, updated_at, custom_attributes (None)
     self.general_equal_assert(expected_controls, actual_controls,
                               *Representation.tree_view_attrs_to_exclude)
Пример #2
0
 def test_bulk_update_audit_objects_to_latest_ver(
         self, create_audit_and_update_first_of_two_original_controls,
         selenium):
     """Check via UI that Audit contains snapshotable Controls that up-to-date
 with their actual states after bulk updated audit objects
 to latest version.
 Preconditions:
 - Execution and return of fixture
   'create_audit_and_update_first_of_two_original_controls'.
 """
     audit_with_two_controls = (
         create_audit_and_update_first_of_two_original_controls)
     audit = audit_with_two_controls["audit"]
     # due to 'actual_control.custom_attributes = {None: None}'
     expected_controls = [
         expected_control.repr_ui().update_attrs(
             custom_attributes={None: None}) for expected_control in [
                 audit_with_two_controls["updated_control"],
                 audit_with_two_controls["second_control"]
             ]
     ]
     (webui_service.AuditsService(selenium).bulk_update_via_info_page(
         audit_obj=audit))
     actual_controls_tab_count = (
         webui_service.ControlsService(selenium).get_count_objs_from_tab(
             src_obj=audit))
     assert len(expected_controls) == actual_controls_tab_count
     actual_controls = (webui_service.ControlsService(
         selenium).get_list_objs_from_tree_view(src_obj=audit))
     assert expected_controls == actual_controls, (
         messages.ERR_MSG_FORMAT.format(expected_controls, actual_controls))
Пример #3
0
 def create_and_clone_audit(
     self, new_program_rest, new_control_rest, map_control_to_program_rest,
     new_audit_rest, new_asmt_rest, new_asmt_tmpl_rest, new_issue_rest,
     map_issue_to_audit_rest, selenium
 ):
   """Create Audit with clonable and non clonable objects via REST API and
   clone it with them via UI.
   Preconditions:
   - Program, Control created via REST API.
   - Control mapped to Program via REST API.
   - Audit created under Program via REST API.
   - Assessment, Assessment Template, Issue created under Audit via REST API.
   - Issue mapped to Audit via REST API.
   """
   # pylint: disable=too-many-locals
   expected_audit = AuditsFactory().clone(audit=new_audit_rest[0])[0]
   expected_asmt_tmpl = AssessmentTemplatesFactory().clone(
       asmt_tmpl=new_asmt_tmpl_rest[0])[0]
   actual_audit = (webui_service.AuditsService(selenium).
                   clone_via_info_widget_get_obj(audit_obj=new_audit_rest[0]))
   return {
       "audit": new_audit_rest[0], "expected_audit": expected_audit,
       "actual_audit": actual_audit, "asmt": new_asmt_rest[0],
       "issue": new_issue_rest[0], "asmt_tmpl": new_asmt_tmpl_rest[0],
       "expected_asmt_tmpl": expected_asmt_tmpl,
       "control": new_control_rest, "program": new_program_rest}
Пример #4
0
def create_audit(selenium, program, **kwargs):
    """Create audit via UI."""
    audit = entities_factory.AuditsFactory().create(**kwargs)
    audits_service = webui_service.AuditsService(selenium)
    audits_service.create_obj_via_tree_view(program, audit)
    audit.url = audits_service.open_widget_of_mapped_objs(
        program).tree_view.tree_view_items()[0].url()
    return audit
Пример #5
0
 def test_page_on_dashboard_gca(self, audit, soft_assert, selenium):
   """Check that Dashboard Tab displays login page if 'Dashboard' GCA filled
   with appropriate url."""
   rest_facade.cas_dashboards(audit, environment.app_url)
   dashboard_content = login_page.LoginPage(
       webui_service.AuditsService(selenium).get_dashboard_content(audit))
   for element in dashboard_content.get_visible_elements():
     soft_assert.expect(element.exists, "{} is not found".format(element))
   soft_assert.assert_expectations()
Пример #6
0
 def test_create_audit(self, program, selenium):
     """Test creation of an audit via UI."""
     audit = entities_factory.AuditsFactory().create()
     audits_service = webui_service.AuditsService(selenium)
     audits_service.create_obj_via_tree_view(program, audit)
     tree_view_audit = audits_service.get_list_objs_from_tree_view(
         program)[0]
     actual_audit = audits_service.get_obj_from_info_page(tree_view_audit)
     rest_audit = rest_facade.get_obj(actual_audit)
     audit.update_attrs(created_at=rest_audit.created_at,
                        updated_at=rest_audit.updated_at,
                        modified_by=users.current_user(),
                        slug=rest_audit.slug).repr_ui()
     self.general_equal_assert(audit, actual_audit, "custom_attributes")
Пример #7
0
 def create_and_clone_audit_w_params_to_update(
         self, request, new_program_rest, new_control_rest,
         map_new_program_rest_to_new_control_rest, new_audit_rest,
         new_assessment_rest, new_assessment_template_rest, new_issue_rest,
         selenium):
     """Create Audit with clonable and non clonable objects via REST API and
 clone it with them via UI.
 Preconditions:
 - Program, Control created via REST API.
 - Control mapped to Program via REST API.
 - Audit created under Program via REST API.
 - Assessment, Assessment Template, Issue created under Audit via REST API.
 - Issue mapped to Audit via REST API.
 """
     # pylint: disable=too-many-locals
     if hasattr(request, "param") and request.param:
         if isinstance(request.param, tuple):
             fixture, params_to_update = request.param
             # fixtures which are objects
             if fixture in request.fixturenames and fixture.startswith(
                     "new_"):
                 fixture = locals().get(fixture)
                 (get_cls_rest_service(objects.get_plural(
                     fixture.type))().update_obj(obj=fixture,
                                                 **params_to_update))
     expected_audit = entities_factory.AuditsFactory().clone(
         audit=new_audit_rest)[0]
     expected_asmt_tmpl = entities_factory.AssessmentTemplatesFactory(
     ).clone(asmt_tmpl=new_assessment_template_rest)[0]
     actual_audit = (webui_service.AuditsService(
         selenium).clone_via_info_page_and_get_obj(
             audit_obj=new_audit_rest))
     return {
         "audit": new_audit_rest,
         "expected_audit": expected_audit,
         "actual_audit": actual_audit,
         "assessment": new_assessment_rest,
         "issue": new_issue_rest,
         "assessment_template": new_assessment_template_rest,
         "expected_assessment_template": expected_asmt_tmpl,
         "control": new_control_rest,
         "program": new_program_rest
     }
Пример #8
0
 def test_dashboard_gca(self, audit, soft_assert, selenium):
   # pylint: disable=anomalous-backslash-in-string
   """Check Dashboard Tab is exist if 'Dashboard' GCA filled
   with right value. Possible values match to regexp r"^https?://[^\s]+$".
   Steps:
     - Create 'Dashboard' gcas for object.
     - Fill with values
     - Check if 'Dashboard' tab exist.
     - Navigate to 'Dashboard' tab.
     - Check only GCAs filled with right values displayed on the tab.
   """
   expected_tabs = rest_facade.cas_dashboards(
       audit, "https://gmail.by/", "https://www.google.com/",
       environment.app_url, string_utils.StringMethods.random_string(),
       "ftp://something.com/")
   audit_ui_service = webui_service.AuditsService(selenium)
   soft_assert.expect(audit_ui_service.is_dashboard_tab_exist(audit),
                      "Dashboard tab should be displayed.")
   soft_assert.expect(
       expected_tabs == audit_ui_service.get_items_from_dashboard_widget(
           audit), "Dashboard tab items are not displayed correctly.")
   soft_assert.assert_expectations()
Пример #9
0
 def test_bulk_update_audit_objects_to_latest_ver(
     self, create_audit_and_update_first_of_two_original_controls, selenium
 ):
   """Check via UI that Audit contains snapshotable Controls that up-to-date
   with their actual states after bulk updated audit objects to latest ver.
   Preconditions:
   - Execution and return of fixture
     'create_audit_and_update_first_of_two_original_controls'.
   """
   audit_with_two_controls = (
       create_audit_and_update_first_of_two_original_controls)
   audit = audit_with_two_controls["audit"]
   expected_controls = [audit_with_two_controls["updated_control"],
                        audit_with_two_controls["second_control"]]
   (webui_service.AuditsService(selenium).
    bulk_update_via_info_widget(audit_obj=audit))
   actual_controls_tab_count = (webui_service.ControlsService(selenium).
                                get_count_from_tab(source_obj=audit))
   assert len(expected_controls) == actual_controls_tab_count
   actual_controls = (webui_service.ControlsService(selenium).
                      get_objs_from_tree_view(source_obj=audit))
   assert expected_controls == actual_controls, (
       messages.ERR_MSG_FORMAT.format(expected_controls, actual_controls))