def test_fill_asmt_lcas(self, control_mapped_to_program, audit,
                         attr_type, selenium):
   """
   1. Create a program via REST
   2. Create a control within a program via REST
   3. Create an audit within a program via REST
   4. Create an assessment template with each type of
    local custom attribute within audit via REST
   5. Generate an assessment from assessment template and control
    snapshot via REST
   6. Open this assessment in UI
   7. Fill local custom attribute
   8. Reload page and check that object built from the page looks as expected
   """
   asmt_template = rest_facade.create_asmt_template(
       audit=audit, assessment_type="Control", cad_type=attr_type)
   cas = CustomAttributeDefinitionsFactory().generate_custom_attributes([
       Representation.repr_dict_to_obj(cad)
       for cad in asmt_template.custom_attribute_definitions])
   exp_asmt = rest_facade.create_asmt_from_template(
       audit, asmt_template, control_mapped_to_program)
   asmts_ui_service = webui_service.AssessmentsService(selenium)
   asmts_ui_service.fill_asmt_lcas(exp_asmt, cas)
   selenium.refresh()
   act_asmt = self.info_service().get_obj(obj=exp_asmt)
   exp_asmt.update_attrs(updated_at=act_asmt.updated_at,
                         status=unicode(object_states.IN_PROGRESS),
                         mapped_objects=[control_mapped_to_program],
                         custom_attributes=cas)
   _assert_asmt(asmts_ui_service, exp_asmt)
Beispiel #2
0
 def test_set_comment_for_dropdown_lca(self, program,
                                       control_mapped_to_program,
                                       login_role, obj, obj_role, selenium):
     """Check evidence comment could be filled in
 via Assessment dropdown.
 Objects structure:
 Program.
 -> Control mapped to program.
 -> Audit.
   -> Asmt template with evidence comment dropdown.
     -> Autogenerated asmt.
 """
     # pylint: disable=too-many-locals
     user = rest_facade.create_user_with_role(login_role)
     obj_args = {obj_role: [user]}
     audit = rest_facade.create_audit(program,
                                      **obj_args if obj == "audit" else {})
     comment_text = entities_factory.CommentsFactory().create().description
     asmt_template_w_dropdown = rest_facade.create_asmt_template(
         audit,
         cad_type=AdminWidgetCustomAttributes.DROPDOWN,
         dropdown_types_list=["comment"],
         **obj_args if obj == "assessment" else {})
     expected_asmt = rest_facade.create_asmt_from_template(
         audit, asmt_template_w_dropdown, [control_mapped_to_program])
     dropdown = CustomAttributeDefinitionsFactory().create(
         **expected_asmt.cads_from_template()[0])
     users.set_current_user(user)
     asmt_service = webui_service.AssessmentsService(selenium)
     asmt_service.choose_and_fill_dropdown_lca(expected_asmt,
                                               dropdown,
                                               comment=comment_text)
     rest_asmt_obj = self.info_service().get_obj(obj=expected_asmt)
     expected_asmt.update_attrs(
         custom_attributes={
             dropdown.title.upper(): dropdown.multi_choice_options
         },
         updated_at=rest_asmt_obj.updated_at,
         modified_by=rest_asmt_obj.modified_by,
         mapped_objects=[control_mapped_to_program.title],
         status=object_states.IN_PROGRESS).repr_ui()
     actual_asmt = asmt_service.get_obj_from_info_page(obj=expected_asmt)
     actual_comment_texts = [
         comment["description"] for comment in actual_asmt.comments
     ]
     self.general_equal_assert(expected_asmt, actual_asmt, "audit",
                               "comments")
     assert actual_comment_texts == [comment_text]
Beispiel #3
0
 def test_set_url_for_dropdown_lca(self, program, control_mapped_to_program,
                                   login_role, obj, obj_role, selenium):
     """Check evidence url could be filled in
 via Assessment dropdown.
 Objects structure:
 Program.
 -> Control mapped to program.
 -> Audit.
   -> Asmt template with evidence url dropdown.
     -> Autogenerated asmt.
 """
     user = rest_facade.create_user_with_role(login_role)
     obj_args = {obj_role: [user]}
     audit = rest_facade.create_audit(program,
                                      **obj_args if obj == "audit" else {})
     url = StringMethods.random_string()
     asmt_template_w_dropdown = rest_facade.create_asmt_template(
         audit,
         cad_type=AdminWidgetCustomAttributes.DROPDOWN,
         dropdown_types_list=["url"],
         **obj_args if obj == "assessment" else {})
     expected_asmt = rest_facade.create_asmt_from_template(
         audit, asmt_template_w_dropdown, [control_mapped_to_program])
     dropdown = CustomAttributeDefinitionsFactory().create(
         **expected_asmt.cads_from_template()[0])
     users.set_current_user(user)
     asmt_service = webui_service.AssessmentsService(selenium)
     asmt_service.choose_and_fill_dropdown_lca(expected_asmt,
                                               dropdown,
                                               url=url)
     rest_asmt_obj = self.info_service().get_obj(expected_asmt)
     expected_asmt.update_attrs(
         custom_attributes={
             dropdown.title.upper(): dropdown.multi_choice_options
         },
         updated_at=rest_asmt_obj.updated_at,
         modified_by=rest_asmt_obj.modified_by,
         evidence_urls=[url],
         mapped_objects=[control_mapped_to_program.title],
         status=object_states.IN_PROGRESS)
     _assert_asmt(asmt_service, expected_asmt)
Beispiel #4
0
def assessment_template_with_all_cas_rest(audit):
    """Create asmt template with all ca types."""
    return rest_facade.create_asmt_template(audit,
                                            all_cad_types=True,
                                            assessment_type="Control")
Beispiel #5
0
def assessment_template_with_all_cas_rest(audit):
  """Create asmt template with all ca types."""
  return rest_facade.create_asmt_template(
      audit, all_cad_types=True, assessment_type="Control")