def gcads_for_asmt(): """Creates GCADs of all types for Assessment.""" return [ rest_facade.create_gcad(definition_type="assessment", attribute_type=ca_type) for ca_type in element.AdminWidgetCustomAttributes.ALL_GCA_TYPES ]
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 edit_gca(selenium, ca_type): """Create Global Custom attribute via rest api and edit it via web ui. Returns: dict with actual edited CA and expected CA. """ new_ca = rest_facade.create_gcad(definition_type=objects.get_singular( random.choice(objects.OBJS_SUPPORTING_MANDATORY_CA)), attribute_type=ca_type, mandatory=True) expected_ca = copy.deepcopy(new_ca) expected_ca.update_attrs(helptext=element.Common.TITLE_EDITED_PART, mandatory=False) if ca_type in (element.AdminWidgetCustomAttributes.TEXT, element.AdminWidgetCustomAttributes.RICH_TEXT): expected_ca.update_attrs(placeholder=element.Common.TITLE_EDITED_PART) actual_ca = admin_webui_service.CustomAttributeWebUiService( selenium).edit_custom_attribute(new_ca, expected_ca) return {"actual_ca": actual_ca, "expected_ca": expected_ca}
def edit_gca(selenium, old_ca_type, new_ca_type): """Create Global Custom attribute via rest api and edit it via web ui. Returns: dict with actual edited CA and expected CA. """ new_ca = rest_facade.create_gcad(definition_type=objects.get_singular( random.choice(objects.EDITABLE_CA_OBJS)), attribute_type=old_ca_type, mandatory=True) expected_ca = entities_factory.CustomAttributeDefinitionsFactory().create( attribute_type=new_ca_type, definition_type=new_ca.definition_type, helptext=element.Common.TITLE_EDITED_PART, mandatory=False) if new_ca_type in (element.AdminWidgetCustomAttributes.TEXT, element.AdminWidgetCustomAttributes.RICH_TEXT): expected_ca.update_attrs(placeholder=element.Common.TITLE_EDITED_PART) actual_ca = admin_webui_service.CustomAttributeWebUiService( selenium).edit_custom_attribute(new_ca, expected_ca) return {"actual_ca": actual_ca, "expected_ca": expected_ca}
def test_fill_asmt_gcas_inline(self, program, audit, assessment, attr_type, selenium): """Test for checking population of GCA from UI inline fields. Preconditions: - Program created via REST API. - Audit created via REST API. - Global Custom Attributes for Assessment created via REST API. - Assessment created via REST API. """ gcad = rest_facade.create_gcad(definition_type="assessment", attribute_type=attr_type) custom_attributes = CustomAttributeDefinitionsFactory( ).generate_custom_attributes([gcad]) asmts_ui_service = webui_service.AssessmentsService(selenium) asmts_ui_service.fill_obj_gcas_inline(assessment, custom_attributes) selenium.refresh() actual_asmt = rest_facade.get_obj(assessment) assessment.update_attrs(updated_at=actual_asmt.updated_at, status=actual_asmt.status, custom_attributes=custom_attributes) _assert_asmt(asmts_ui_service, assessment)
def gcads_for_asmt(): """Creates GCADs of all types for Assessment.""" return [rest_facade.create_gcad(definition_type="assessment", attribute_type=ca_type) for ca_type in element.AdminWidgetCustomAttributes.ALL_CA_TYPES]