def create(cls, type=None, id=None, title=None, href=None, url=None, slug=None, status=None, owners=None, audit=None, recipients=None, assignees=None, verified=None, verifier=None, creator=None, assessor=None, updated_at=None, objects_under_assessment=None, custom_attribute_definitions=None, custom_attribute_values=None, custom_attributes=None, created_at=None, modified_by=None): """Create Assessment object. Random values will be used for title and slug. Predictable values will be used for type, status, recipients, verified, owners. """ # pylint: disable=too-many-locals asmt_entity = cls._create_random_asmt() asmt_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=asmt_entity, is_allow_none_values=False, type=type, id=id, title=title, href=href, url=url, slug=slug, status=status, owners=owners, audit=audit, recipients=recipients, assignees=assignees, verified=verified, verifier=verifier, creator=creator, assessor=assessor, updated_at=updated_at, objects_under_assessment=objects_under_assessment, custom_attribute_definitions=custom_attribute_definitions, custom_attribute_values=custom_attribute_values, custom_attributes=custom_attributes, created_at=created_at, modified_by=modified_by) return asmt_entity
def generate(cls, objs_under_asmt, audit, asmt_tmpl=None): """Generate Assessment objects according to objects under Assessment, Audit, Assessment Template. If 'asmt_tmpl' then generate with Assessment Template, if not 'asmt_tmpl' then generate without Assessment Template. Slug will not be predicted to avoid of rising errors in case of tests parallel running. Predictable values will be used for type, title, audit, objects_under_assessment custom_attribute_definitions and custom_attribute_values. """ # pylint: disable=too-many-locals cas_def = asmt_tmpl.custom_attribute_definitions if asmt_tmpl and getattr( asmt_tmpl, "custom_attribute_definitions") else None asmts_objs = [ cls.create(title=obj_under_asmt.title + " assessment for " + audit.title, audit=audit.title, objects_under_assessment=[obj_under_asmt], custom_attribute_definitions=cas_def, verifier=[audit.contact["name"]]) for obj_under_asmt in objs_under_asmt ] return [ Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=asmt_obj, slug=None) for asmt_obj in asmts_objs ]
def create(cls, type=None, id=None, title=None, href=None, url=None, slug=None, status=None, owners=None, audit=None, recipients=None, assignees=None, verified=None, verifier=None, creator=None, assignee=None, updated_at=None, objects_under_assessment=None, custom_attribute_definitions=None, custom_attribute_values=None, custom_attributes=None, created_at=None, modified_by=None): """Create Assessment object. Random values will be used for title and slug. Predictable values will be used for type, status, recipients, verified, owners. """ # pylint: disable=too-many-locals asmt_entity = cls._create_random_asmt() asmt_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=asmt_entity, is_allow_none_values=False, type=type, id=id, title=title, href=href, url=url, slug=slug, status=status, owners=owners, audit=audit, recipients=recipients, assignees=assignees, verified=verified, verifier=verifier, creator=creator, assignee=assignee, updated_at=updated_at, objects_under_assessment=objects_under_assessment, custom_attribute_definitions=custom_attribute_definitions, custom_attribute_values=custom_attribute_values, custom_attributes=custom_attributes, created_at=created_at, modified_by=modified_by) if verifier: asmt_entity.access_control_list.append( ObjectPersonsFactory.get_acl_member(roles.ASMT_VERIFIER_ID, cls.default_person)) return asmt_entity
def _update_ca_attrs_values(cls, obj, **arguments): """Update CA's (obj) attributes values according to dictionary of arguments (key = value). Restrictions: 'multi_choice_options' is a mandatory attribute for Dropdown CA and 'placeholder' is a attribute that exists only for Text and Rich Text CA. Generated data - 'obj', entered data - '**arguments'. """ # fix generated data if arguments.get("attribute_type"): obj.title = cls.generate_string(arguments["attribute_type"]) if (obj.multi_choice_options and obj.attribute_type == AdminWidgetCustomAttributes.DROPDOWN and arguments.get("attribute_type") != AdminWidgetCustomAttributes.DROPDOWN): obj.multi_choice_options = None # fix entered data if (arguments.get("multi_choice_options") and arguments.get("attribute_type") != AdminWidgetCustomAttributes.DROPDOWN): arguments["multi_choice_options"] = None if (arguments.get("placeholder") and arguments.get("attribute_type") not in (AdminWidgetCustomAttributes.TEXT, AdminWidgetCustomAttributes.RICH_TEXT)): arguments["placeholder"] = None # extend entered data if (arguments.get("attribute_type") == AdminWidgetCustomAttributes.DROPDOWN and not obj.multi_choice_options): obj.multi_choice_options = random_list_strings() return Entity.update_objs_attrs_values_by_entered_data(obj_or_objs=obj, **arguments)
def create(cls, type=None, id=None, name=None, href=None, url=None, email=None, company=None, system_wide_role=None, updated_at=None, custom_attribute_definitions=None, custom_attribute_values=None, custom_attributes=None): """Create Person object. Random values will be used for name. Predictable values will be used for type, email and system_wide_role. """ person_entity = cls._create_random_person() person_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=person_entity, is_allow_none_values=False, type=type, id=id, name=name, href=href, url=url, email=email, company=company, system_wide_role=system_wide_role, updated_at=updated_at, custom_attribute_definitions=custom_attribute_definitions, custom_attribute_values=custom_attribute_values, custom_attributes=custom_attributes) return person_entity
def _update_ca_attrs_values(cls, obj, **arguments): """Update CA's (obj) attributes values according to dictionary of arguments (key = value). Restrictions: 'multi_choice_options' is a mandatory attribute for Dropdown CA and 'placeholder' is a attribute that exists only for Text and Rich Text CA. Generated data - 'obj', entered data - '**arguments'. """ # fix generated data if arguments.get("attribute_type"): obj.title = cls.generate_string(arguments["attribute_type"]) if (obj.multi_choice_options and obj.attribute_type == AdminWidgetCustomAttributes.DROPDOWN and arguments.get("attribute_type") != AdminWidgetCustomAttributes.DROPDOWN): obj.multi_choice_options = None # fix entered data if (arguments.get("multi_choice_options") and arguments.get("attribute_type") != AdminWidgetCustomAttributes.DROPDOWN): arguments["multi_choice_options"] = None if (arguments.get("placeholder") and arguments.get("attribute_type") not in (AdminWidgetCustomAttributes.TEXT, AdminWidgetCustomAttributes.RICH_TEXT)): arguments["placeholder"] = None # extend entered data if (arguments.get("attribute_type") == AdminWidgetCustomAttributes.DROPDOWN and not obj.multi_choice_options): obj.multi_choice_options = random_list_strings() return Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=obj, **arguments)
def create(cls, type=None, id=None, title=None, href=None, url=None, slug=None, status=None, owners=None, audit=None, recipients=None, assignees=None, verified=None, verifier=None, creator=None, assessor=None, updated_at=None, objects_under_assessment=None, custom_attribute_definitions=None, custom_attribute_values=None, custom_attributes=None, created_at=None, modified_by=None): """Create Assessment object. Random values will be used for title and slug. Predictable values will be used for type, status, recipients, verified, owners. """ # pylint: disable=too-many-locals asmt_entity = cls._create_random_asmt() asmt_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=asmt_entity, is_allow_none_values=False, type=type, id=id, title=title, href=href, url=url, slug=slug, status=status, owners=owners, audit=audit, recipients=recipients, assignees=assignees, verified=verified, verifier=verifier, creator=creator, assessor=assessor, updated_at=updated_at, objects_under_assessment=objects_under_assessment, custom_attribute_definitions=custom_attribute_definitions, custom_attribute_values=custom_attribute_values, custom_attributes=custom_attributes, created_at=created_at, modified_by=modified_by) return asmt_entity
def clone(cls, asmt_tmpl, count_to_clone=1): """Clone Assessment Template object. Predictable values will be used for type, title. """ # pylint: disable=anomalous-backslash-in-string return [Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=copy.deepcopy(asmt_tmpl), slug=None, updated_at=None, href=None, url=None, id=None) for _ in xrange(1, count_to_clone + 1)]
def _update_asmt_attrs_values(cls, obj, **arguments): """Update Assessments (obj) attributes values according to dictionary of arguments (key = value). Generated data-'obj', entered data-'**arguments'. """ if arguments.get("verifier"): obj.assignees['Verifier'] = [cls.default_person.__dict__] return Entity.update_objs_attrs_values_by_entered_data(obj_or_objs=obj, **arguments)
def clone(cls, asmt_tmpl, count_to_clone=1): """Clone Assessment Template object. Predictable values will be used for type, title. """ # pylint: disable=anomalous-backslash-in-string return [Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=copy.deepcopy(asmt_tmpl), slug=None, updated_at=None, href=None, url=None, id=None) for _ in xrange(1, count_to_clone + 1)]
def create_list_objs(self, entity_factory, list_scopes): """Create and return list of objects used entity factory and UI data (list of scopes UI text elements {"header": "item", ...} remapped to list of dicts {"attr": "value", ...}). Return list of created objects. """ list_factory_objs = [ entity_factory.create_empty() for _ in xrange(len(list_scopes)) ] list_scopes_with_upper_keys = [ string_utils.dict_keys_to_upper_case(scope) for scope in list_scopes ] list_scopes_to_convert = string_utils.exchange_dicts_items( transform_dict=Entity.items_of_remap_keys(), dicts=list_scopes_with_upper_keys, is_keys_not_values=True) # convert and represent values in scopes for scope in list_scopes_to_convert: # convert u'None', u'No person' to None type string_utils.update_dicts_values(scope, ["None", "No person"], None) for key, val in scope.iteritems(): if val: if key in ["mandatory", "verified"]: # convert u'false', u'true' like to Boolean scope[key] = string_utils.get_bool_value_from_arg(val) # convert datetime attributes' directly if key in ["updated_at", "created_at"]: scope[key] = string_utils.convert_str_to_datetime(val) # convert datetime attributes' in 'comments' if (key == "comments" and isinstance(val, list) and all( isinstance(comment, dict) for comment in val)): # u'(Creator) 07/06/2017 05:47:14 AM UTC' # to u'07/06/2017 05:47:14 AM UTC' scope[key] = [{ k: (string_utils.convert_str_to_datetime( re.sub(regex.TEXT_WITHIN_PARENTHESES, "", v)) if k == "created_at" else v) for k, v in comment.iteritems() } for comment in val] # convert multiple values to list of strings and split if need it if key in ["owners", "assessor", "creator", "verifier"]: # convert CSV like u'*****@*****.**' to u'Example User' val = val if val != url.DEFAULT_USER_EMAIL else roles.DEFAULT_USER # split multiple values if need 'Ex1, Ex2 F' to ['Ex1', 'Ex2 F'] scope[key] = val.split(", ") # convert 'slug' from CSV for snapshoted objects u'*23eb72ac-4d9d' if (key == "slug" and (self.obj_name in objects.ALL_SNAPSHOTABLE_OBJS) and "*" in val): scope[key] = val.replace("*", "") return [ Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=factory_obj, is_allow_none_values=False, **scope) for scope, factory_obj in zip(list_scopes_to_convert, list_factory_objs) ]
def _create_list_objs(self, entity_factory, list_scopes): """Create and return list of objects used entity factory and UI data (list of scopes UI text elements {"header": "item", ...} remapped to list of dicts {"attr": "value", ...}). Return list of created objects. """ list_factory_objs = [ entity_factory.create_empty() for _ in xrange(len(list_scopes))] list_scopes_with_upper_keys = [ StringMethods.dict_keys_to_upper_case(scope) for scope in list_scopes] list_scopes_to_convert = StringMethods.exchange_dicts_items( transform_dict=Entity.items_of_remap_keys(), dicts=list_scopes_with_upper_keys, is_keys_not_values=True) # convert and represent values in scopes for scope in list_scopes_to_convert: # convert u'None', u'No person' to None type StringMethods.update_dicts_values(scope, ["None", "No person"], None) for key, val in scope.iteritems(): if val: if key in ["mandatory", "verified"]: # convert u'false', u'true' like to Boolean scope[key] = StringMethods.get_bool_value_from_arg(val) if key in ["updated_at", "created_at"]: # UI like u'08/20/2017' to date=2017-08-20, timetz=00:00:00 datetime_val = parser.parse(val) if str(datetime_val.time()) != "00:00:00": # UI like u'08/20/2017 07:30:45 AM +03:00' to date=2017-08-20, # timetz=04:30:45+00:00 if 'tzinfo', else: # CSV like u'08-20-2017 04:30:45' to date=2017-08-20, # timetz=04:30:45+00:00 datetime_val = ( datetime_val.astimezone(tz=tz.tzutc()) if datetime_val.tzinfo else datetime_val.replace(tzinfo=tz.tzutc())) scope[key] = datetime_val if (key == "comments" and isinstance(val, list) and all(isinstance(comment, dict) for comment in val)): # extract datetime from u'(Creator) 08/20/2017 07:30:45 AM +03:00' scope[key] = [ {k: (parser.parse(re.sub(regex.TEXT_W_PARENTHESES, Symbols.BLANK, v) ).astimezone(tz=tz.tzutc()) if k == "created_at" else v) for k, v in comment.iteritems()} for comment in val] # convert multiple values to list of strings and split if need it if (key in ["owners", "assignee", "creator", "verifier"] and not isinstance(val, list)): # split Tree View values if need 'Ex1, Ex2 F' to ['Ex1', 'Ex2 F'] # Info Widget values will be represent by internal methods scope[key] = val.split(", ") # convert 'slug' from CSV for snapshoted objects u'*23eb72ac-4d9d' if (key == "slug" and (self.obj_name in objects.ALL_SNAPSHOTABLE_OBJS) and Symbols.STAR in val): scope[key] = val.replace(Symbols.STAR, Symbols.BLANK) return [ Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=factory_obj, is_allow_none_values=False, **scope) for scope, factory_obj in zip(list_scopes_to_convert, list_factory_objs)]
def create(cls, **attrs): """Create Control object. Random values will be used for title and slug. Predictable values will be used for type, status, owners and contact. """ control_entity = cls._create_random_control() control_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=control_entity, is_allow_none_values=False, **attrs) return control_entity
def create(cls, **attrs): """Create Objective object. Random values will be used for title and slug. Predictable values will be used for type, status, owners. """ objective_entity = cls._create_random_objective() objective_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=objective_entity, is_allow_none_values=False, **attrs) return objective_entity
def create(cls, **attrs): """Create Program object. Random values will be used for title and slug. Predictable values will be used for type, status, manager, contact. """ program_entity = cls._create_random_program() program_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=program_entity, is_allow_none_values=False, **attrs) return program_entity
def create(cls, **attrs): """Create Person object. Random values will be used for name. Predictable values will be used for type, email and system_wide_role. """ person_entity = cls._create_random_person() person_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=person_entity, is_allow_none_values=False, **attrs) return person_entity
def _create_list_objs(self, entity_factory, list_scopes): """Create and return list of objects used entity factory and UI data (list of scopes UI text elements {"header": "item", ...} remapped to list of dicts {"attr": "value", ...}). Return list of created objects. """ list_factory_objs = [ entity_factory.create_empty() for _ in xrange(len(list_scopes))] list_scopes_with_upper_keys = [ string_utils.dict_keys_to_upper_case(scope) for scope in list_scopes] list_scopes_to_convert = string_utils.exchange_dicts_items( transform_dict=Entity.items_of_remap_keys(), dicts=list_scopes_with_upper_keys, is_keys_not_values=True) # convert and represent values in scopes for scope in list_scopes_to_convert: # convert u'None', u'No person' to None type string_utils.update_dicts_values(scope, ["None", "No person"], None) for key, val in scope.iteritems(): if val: if key in ["mandatory", "verified"]: # convert u'false', u'true' like to Boolean scope[key] = string_utils.get_bool_value_from_arg(val) if key in ["updated_at", "created_at"]: # UI like u'08/20/2017' to date=2017-08-20, timetz=00:00:00 datetime_val = parser.parse(val) if str(datetime_val.time()) != "00:00:00": # UI like u'08/20/2017 07:30:45 AM +03:00' to date=2017-08-20, # timetz=04:30:45+00:00 if 'tzinfo', else: # CSV like u'08-20-2017 04:30:45' to date=2017-08-20, # timetz=04:30:45+00:00 datetime_val = ( datetime_val.astimezone(tz=tz.tzutc()) if datetime_val.tzinfo else datetime_val.replace(tzinfo=tz.tzutc())) scope[key] = datetime_val if (key == "comments" and isinstance(val, list) and all(isinstance(comment, dict) for comment in val)): # extract datetime from u'(Creator) 08/20/2017 07:30:45 AM +03:00' scope[key] = [ {k: (parser.parse(re.sub(regex.TEXT_WITHIN_PARENTHESES, string_utils.BLANK, v) ).astimezone(tz=tz.tzutc()) if k == "created_at" else v) for k, v in comment.iteritems()} for comment in val] # convert multiple values to list of strings and split if need it if key in ["owners", "assessor", "creator", "verifier"]: # split multiple values if need 'Ex1, Ex2 F' to ['Ex1', 'Ex2 F'] scope[key] = val.split(", ") # convert 'slug' from CSV for snapshoted objects u'*23eb72ac-4d9d' if (key == "slug" and (self.obj_name in objects.ALL_SNAPSHOTABLE_OBJS) and string_utils.STAR in val): scope[key] = val.replace(string_utils.STAR, string_utils.BLANK) return [ Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=factory_obj, is_allow_none_values=False, **scope) for scope, factory_obj in zip(list_scopes_to_convert, list_factory_objs)]
def create(cls, **attrs): """Create Audit object. Random values will be used for title and slug. Predictable values will be used for type, status, contact. """ # pylint: disable=too-many-locals audit_entity = cls._create_random_audit() audit_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=audit_entity, is_allow_none_values=False, **attrs) return audit_entity
def create(cls, **attrs): """Create Issue object. Random values will be used for title and slug. Predictable values will be used for type, status, owners and contact. """ # pylint: disable=too-many-locals issue_entity = cls._create_random_issue() issue_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=issue_entity, is_allow_none_values=False, **attrs) return issue_entity
def clone(cls, audit, count_to_clone=1): """Clone Audit object. Predictable values will be used for type, title. """ # pylint: disable=anomalous-backslash-in-string return [Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=copy.deepcopy(audit), title=audit.title + " - copy " + str(num), slug=None, created_at=None, updated_at=None, href=None, url=None, id=None) for num in xrange(1, count_to_clone + 1)]
def clone(cls, audit, count_to_clone=1): """Clone Audit object. Predictable values will be used for type, title. """ # pylint: disable=anomalous-backslash-in-string return [Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=copy.deepcopy(audit), title=audit.title + " - copy " + str(num), slug=None, created_at=None, updated_at=None, href=None, url=None, id=None) for num in xrange(1, count_to_clone + 1)]
def create(cls, **attrs): """Create Assessment Template object. Random values will be used for title and slug. Predictable values will be used for type, template_object_type and default_people {"verifiers": *, "assignees": *}. """ # pylint: disable=too-many-locals asmt_tmpl_entity = cls._create_random_asmt_tmpl() asmt_tmpl_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=asmt_tmpl_entity, is_allow_none_values=False, **attrs) return asmt_tmpl_entity
def create(cls, type=None, id=None, href=None, modified_by=None, created_at=None, description=None): """Create Comment object. Random values will be used for description. Predictable values will be used for type, owners, modified_by. """ comment_entity = cls._create_random_comment() comment_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=comment_entity, is_allow_none_values=False, type=type, id=id, href=href, modified_by=modified_by, created_at=created_at, description=description) return comment_entity
def create(cls, type=None, id=None, href=None, modified_by=None, created_at=None, description=None): """Create Comment object. Random values will be used for description. Predictable values will be used for type, owners, modified_by. """ comment_entity = cls._create_random_comment() comment_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=comment_entity, is_allow_none_values=False, type=type, id=id, href=href, modified_by=modified_by, created_at=created_at, description=description) return comment_entity
def create(cls, **attrs): """Create Assessment object. Random values will be used for title and slug. Predictable values will be used for type, status, recipients, verified, owners. """ # pylint: disable=too-many-locals asmt_entity = cls._create_random_asmt() asmt_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=asmt_entity, is_allow_none_values=False, **attrs) if attrs.get("verifier"): asmt_entity.access_control_list.append( ObjectPersonsFactory.get_acl_member(roles.ASMT_VERIFIER_ID, cls.default_person)) return asmt_entity
def create(cls, type=None, id=None, title=None, href=None, url=None, slug=None, status=None, owners=None, contact=None, secondary_contact=None, updated_at=None, os_state=None, custom_attribute_definitions=None, custom_attribute_values=None, custom_attributes=None, access_control_list=None, created_at=None, modified_by=None): """Create Issue object. Random values will be used for title and slug. Predictable values will be used for type, status, owners and contact. """ # pylint: disable=too-many-locals issue_entity = cls._create_random_issue() issue_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=issue_entity, is_allow_none_values=False, type=type, id=id, title=title, href=href, url=url, slug=slug, status=status, owners=owners, contact=contact, secondary_contact=secondary_contact, updated_at=updated_at, os_state=os_state, custom_attribute_definitions=custom_attribute_definitions, custom_attribute_values=custom_attribute_values, custom_attributes=custom_attributes, access_control_list=access_control_list, created_at=created_at, modified_by=modified_by) return issue_entity
def create(cls, type=None, id=None, name=None, href=None, url=None, email=None, company=None, system_wide_role=None, updated_at=None, custom_attribute_definitions=None, custom_attribute_values=None, custom_attributes=None, created_at=None): """Create Person object. Random values will be used for name. Predictable values will be used for type, email and system_wide_role. """ person_entity = cls._create_random_person() person_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=person_entity, is_allow_none_values=False, type=type, id=id, name=name, href=href, url=url, email=email, company=company, system_wide_role=system_wide_role, updated_at=updated_at, custom_attribute_definitions=custom_attribute_definitions, custom_attribute_values=custom_attribute_values, custom_attributes=custom_attributes, created_at=created_at) return person_entity
def create(cls, type=None, id=None, title=None, href=None, url=None, slug=None, status=None, owners=None, contact=None, secondary_contact=None, updated_at=None, os_state=None, custom_attribute_definitions=None, custom_attribute_values=None, custom_attributes=None, created_at=None, modified_by=None): """Create Objective object. Random values will be used for title and slug. Predictable values will be used for type, status, owners. """ objective_entity = cls._create_random_objective() objective_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=objective_entity, is_allow_none_values=False, type=type, id=id, title=title, href=href, url=url, slug=slug, status=status, owners=owners, contact=contact, secondary_contact=secondary_contact, updated_at=updated_at, os_state=os_state, custom_attribute_definitions=custom_attribute_definitions, custom_attribute_values=custom_attribute_values, custom_attributes=custom_attributes, created_at=created_at, modified_by=modified_by) return objective_entity
def create(cls, type=None, id=None, title=None, href=None, url=None, slug=None, audit=None, default_people=None, template_object_type=None, updated_at=None, custom_attribute_definitions=None, custom_attribute_values=None, custom_attributes=None, created_at=None, modified_by=None, status=None): """Create Assessment Template object. Random values will be used for title and slug. Predictable values will be used for type, template_object_type and default_people {"verifiers": *, "assessors": *}. """ # pylint: disable=too-many-locals asmt_tmpl_entity = cls._create_random_asmt_tmpl() asmt_tmpl_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=asmt_tmpl_entity, is_allow_none_values=False, type=type, id=id, title=title, href=href, url=url, slug=slug, audit=audit, default_people=default_people, template_object_type=template_object_type, updated_at=updated_at, custom_attribute_definitions=custom_attribute_definitions, custom_attribute_values=custom_attribute_values, custom_attributes=custom_attributes, created_at=created_at, modified_by=modified_by, status=status) return asmt_tmpl_entity
def generate(cls, objs_under_asmt, audit, asmt_tmpl=None): """Generate Assessment objects according to objects under Assessment, Audit, Assessment Template. If 'asmt_tmpl' then generate with Assessment Template, if not 'asmt_tmpl' then generate without Assessment Template. Slug will not be predicted to avoid of rising errors in case of tests parallel running. Predictable values will be used for type, title, audit, objects_under_assessment custom_attribute_definitions and custom_attribute_values. """ # pylint: disable=too-many-locals cas_def = asmt_tmpl.custom_attribute_definitions if asmt_tmpl and getattr( asmt_tmpl, "custom_attribute_definitions") else None asmts_objs = [cls.create( title=obj_under_asmt.title + " assessment for " + audit.title, audit=audit.title, objects_under_assessment=[obj_under_asmt], custom_attribute_definitions=cas_def) for obj_under_asmt in objs_under_asmt] return [Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=asmt_obj, slug=None) for asmt_obj in asmts_objs]
def create(cls, type=None, id=None, title=None, href=None, url=None, slug=None, status=None, owners=None, contact=None, secondary_contact=None, updated_at=None, os_state=None, custom_attribute_definitions=None, custom_attribute_values=None, custom_attributes=None, access_control_list=None): """Create Control object. Random values will be used for title and slug. Predictable values will be used for type, status, owners and contact. """ control_entity = cls._create_random_control() control_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=control_entity, is_allow_none_values=False, type=type, id=id, title=title, href=href, url=url, slug=slug, status=status, owners=owners, contact=contact, secondary_contact=secondary_contact, updated_at=updated_at, os_state=os_state, custom_attribute_definitions=custom_attribute_definitions, custom_attribute_values=custom_attribute_values, custom_attributes=custom_attributes, access_control_list=access_control_list) return control_entity
def create(cls, type=None, id=None, title=None, href=None, url=None, slug=None, status=None, owners=None, contact=None, secondary_contact=None, updated_at=None, os_state=None, custom_attribute_definitions=None, custom_attribute_values=None, custom_attributes=None, created_at=None, modified_by=None): """Create Objective object. Random values will be used for title and slug. Predictable values will be used for type, status, owners. """ objective_entity = cls._create_random_objective() objective_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=objective_entity, is_allow_none_values=False, type=type, id=id, title=title, href=href, url=url, slug=slug, status=status, owners=owners, contact=contact, secondary_contact=secondary_contact, updated_at=updated_at, os_state=os_state, custom_attribute_definitions=custom_attribute_definitions, custom_attribute_values=custom_attribute_values, custom_attributes=custom_attributes, created_at=created_at, modified_by=modified_by) return objective_entity
def create(cls, type=None, id=None, title=None, href=None, url=None, slug=None, status=None, program=None, contact=None, updated_at=None, custom_attribute_definitions=None, custom_attribute_values=None, custom_attributes=None, created_at=None, modified_by=None): """Create Audit object. Random values will be used for title and slug. Predictable values will be used for type, status, contact. """ # pylint: disable=too-many-locals audit_entity = cls._create_random_audit() audit_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=audit_entity, is_allow_none_values=False, type=type, id=id, title=title, href=href, url=url, slug=slug, status=status, program=program, contact=contact, updated_at=updated_at, custom_attribute_definitions=custom_attribute_definitions, custom_attribute_values=custom_attribute_values, custom_attributes=custom_attributes, created_at=created_at, modified_by=modified_by) return audit_entity
def create(cls, type=None, id=None, title=None, href=None, url=None, slug=None, status=None, program=None, contact=None, updated_at=None, custom_attribute_definitions=None, custom_attribute_values=None, custom_attributes=None, created_at=None, modified_by=None): """Create Audit object. Random values will be used for title and slug. Predictable values will be used for type, status, contact. """ # pylint: disable=too-many-locals audit_entity = cls._create_random_audit() audit_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=audit_entity, is_allow_none_values=False, type=type, id=id, title=title, href=href, url=url, slug=slug, status=status, program=program, contact=contact, updated_at=updated_at, custom_attribute_definitions=custom_attribute_definitions, custom_attribute_values=custom_attribute_values, custom_attributes=custom_attributes, created_at=created_at, modified_by=modified_by) return audit_entity
def create(cls, type=None, id=None, title=None, href=None, url=None, slug=None, status=None, manager=None, contact=None, secondary_contact=None, updated_at=None, os_state=None, custom_attribute_definitions=None, custom_attribute_values=None, custom_attributes=None): """Create Program object. Random values will be used for title and slug. Predictable values will be used for type, status, manager, contact. """ program_entity = cls._create_random_program() program_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=program_entity, is_allow_none_values=False, type=type, id=id, title=title, href=href, url=url, slug=slug, status=status, manager=manager, contact=contact, secondary_contact=secondary_contact, updated_at=updated_at, os_state=os_state, custom_attribute_definitions=custom_attribute_definitions, custom_attribute_values=custom_attribute_values, custom_attributes=custom_attributes) return program_entity
def create(cls, type=None, id=None, title=None, href=None, url=None, slug=None, audit=None, default_people=None, template_object_type=None, updated_at=None, custom_attribute_definitions=None, custom_attribute_values=None, custom_attributes=None, created_at=None, modified_by=None, status=None): """Create Assessment Template object. Random values will be used for title and slug. Predictable values will be used for type, template_object_type and default_people {"verifiers": *, "assessors": *}. """ # pylint: disable=too-many-locals asmt_tmpl_entity = cls._create_random_asmt_tmpl() asmt_tmpl_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=asmt_tmpl_entity, is_allow_none_values=False, type=type, id=id, title=title, href=href, url=url, slug=slug, audit=audit, default_people=default_people, template_object_type=template_object_type, updated_at=updated_at, custom_attribute_definitions=custom_attribute_definitions, custom_attribute_values=custom_attribute_values, custom_attributes=custom_attributes, created_at=created_at, modified_by=modified_by, status=status) return asmt_tmpl_entity
def create(cls, type=None, id=None, title=None, href=None, url=None, slug=None, status=None, owners=None, contact=None, secondary_contact=None, updated_at=None, os_state=None, custom_attribute_definitions=None, custom_attribute_values=None, custom_attributes=None, access_control_list=None, created_at=None, modified_by=None): """Create Issue object. Random values will be used for title and slug. Predictable values will be used for type, status, owners and contact. """ # pylint: disable=too-many-locals issue_entity = cls._create_random_issue() issue_entity = Entity.update_objs_attrs_values_by_entered_data( obj_or_objs=issue_entity, is_allow_none_values=False, type=type, id=id, title=title, href=href, url=url, slug=slug, status=status, owners=owners, contact=contact, secondary_contact=secondary_contact, updated_at=updated_at, os_state=os_state, custom_attribute_definitions=custom_attribute_definitions, custom_attribute_values=custom_attribute_values, custom_attributes=custom_attributes, access_control_list=access_control_list, created_at=created_at, modified_by=modified_by) return issue_entity