def get_mapping_statuses(self): """Get list of mapping statuses by given titles""" selenium_utils.get_when_all_visible(self._driver, self.locator_titles) objs_titles = self._driver.find_elements(*self.locator_titles) objs_checkboxes = self._driver.find_elements(*self.locator_checkboxes) objs = [ MappingStatusAttrs(obj[0], obj[1][0], obj[1][1]) for obj in zip( [obj.text for obj in objs_titles], [[string_utils.get_bool_from_string(obj.get_attribute("checked")), string_utils.get_bool_from_string(obj.get_attribute("disabled"))] for obj in objs_checkboxes])] return objs
def _set_custom_attributes_list(self): """Set custom attributes list with Custom Attribute objects from current opened content item. """ for row in selenium_utils.get_when_all_visible(self._driver, self._locators.ROW): attrs = [i.text for i in row.find_elements(*self._locators.CELL_IN_ROW)] self.custom_attributes_list.append( CustomAttributeEntity( title=attrs[0], type=objects.get_singular(objects.CUSTOM_ATTRIBUTES), attribute_type=attrs[1], mandatory=get_bool_from_string(attrs[2]), definition_type=self._item_name))
def _set_custom_attributes_list(self): """ Set custom attributes list with CustomAttribute objects from the current opened content item. """ for elem in selenium_utils.get_when_all_visible( self._driver, self._locator.ROW): attr = [ i.text for i in elem.find_elements(*self._locator.CELL_IN_ROW) ] self.custom_attributes_list.append( CustomAttribute(title=attr[0], ca_type=attr[1], is_mandatory=get_bool_from_string(attr[2]), definition_type=self._item_name))
def _set_custom_attributes_list(self): """Set custom attributes list with Custom Attribute objects from current opened content item. """ for row in selenium_utils.get_when_all_visible(self._driver, self._locators.ROW): attrs = [ i.text for i in row.find_elements(*self._locators.CELL_IN_ROW) ] self.custom_attributes_list.append( CustomAttributeEntity(title=attrs[0], type=objects.get_singular( objects.CUSTOM_ATTRIBUTES), attribute_type=attrs[1], mandatory=get_bool_from_string(attrs[2]), definition_type=self._item_name))
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_remapped = string_utils.remap_keys_for_list_dicts( dict_of_transform_keys=Entity.items_of_remap_keys(), list_dicts=list_scopes_with_upper_keys) # add extra 'owners' attribute name and value if 'creator' in scopes list_extra_scopes = [ dict(scope_remapped.items() + [("owners", scope_remapped.get("creator"))]) if "creator" in scope_remapped.keys() else scope_remapped for scope_remapped in list_scopes_remapped ] # convert and represent values in scopes for scope in list_extra_scopes: for key, val in scope.iteritems(): # convert u'false' and u'true' to boolean scope[key] = string_utils.get_bool_from_string(val) # convert multiple values to list of strings if key in ["owners", "assessor", "creator"]: # convert CSV like u'*****@*****.**' to u'Example User' val = val if val != url.DEFAULT_USER_EMAIL else roles.DEFAULT_USER scope[key] = string_utils.convert_to_list(val) # 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 [ EntitiesFactory.update_objs_attrs_values_by_entered_data( objs=factory_obj, is_allow_none_values=False, **scope) for scope, factory_obj in zip(list_extra_scopes, 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 = [ string_utils.dict_keys_to_upper_case(scope) for scope in list_scopes] list_scopes_remapped = string_utils.remap_keys_for_list_dicts( dict_of_transform_keys=Entity.items_of_remap_keys(), list_dicts=list_scopes_with_upper_keys) # add extra 'owners' attribute name and value if 'creator' in scopes list_extra_scopes = [ dict(scope_remapped.items() + [("owners", scope_remapped.get("creator"))]) if "creator" in scope_remapped.keys() else scope_remapped for scope_remapped in list_scopes_remapped] # convert and represent values in scopes for scope in list_extra_scopes: for key, val in scope.iteritems(): # convert u'false' and u'true' to boolean scope[key] = string_utils.get_bool_from_string(val) # convert multiple values to list of strings if key in ["owners", "assessor", "creator"]: # convert CSV like u'*****@*****.**' to u'Example User' val = val if val != url.DEFAULT_USER_EMAIL else roles.DEFAULT_USER scope[key] = string_utils.convert_to_list(val) # 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 [ EntitiesFactory.update_objs_attrs_values_by_entered_data( objs=factory_obj, is_allow_none_values=False, **scope) for scope, factory_obj in zip(list_extra_scopes, list_factory_objs)]
def __eq__(self, other): return (isinstance(other, self.__class__) and self.type == other.type and self.title == other.title and self.slug == other.slug and self.status == other.status and (self.verified == other.verified or self.verified == string_utils.get_bool_from_string(str(other.verified))) and (self.owners == other.owners or other.owners in [owner.values() for owner in self.owners][0]) and ([ obj_under_amt.title for obj_under_amt in self.objects_under_assessment ] == other.objects_under_assessment if isinstance( self.objects_under_assessment, list) else True) and (set(other.custom_attribute_definitions).issubset([ ca_def.values()[1].upper() for ca_def in self.custom_attribute_definitions ]) if other.custom_attribute_definitions else True) and (set(other.custom_attribute_values).issubset([ ca_val.get("attribute_value") for ca_val in self.custom_attribute_values ]) if other.custom_attribute_values and isinstance( self.custom_attribute_values, list) else True))