def __str__(self): """ Display items as a list for printing """ if self._items: # List of identifiers try: return listed(sorted([item.identifier for item in self._items])) # If no identifiers, just join strings except AttributeError: return listed(self._items, quote="'") else: return "[None]"
def _remove(self, plans): """ Remove self as parent of given test plans """ log.info("Removing {1} as parent of {0}".format( self._identifier, listed([plan.identifier for plan in plans]))) for plan in plans: plan.parent = None plan.update()
def _add(self, plans): """ Set self as parent of given test plans """ log.info("Setting {1} as parent of {0}".format( self._identifier, listed([plan.identifier for plan in plans]))) for plan in plans: plan.parent = TestPlan(self.id) plan.update()
def _add(self, components): """ Link provided components to the test case """ log.info("Linking {1} to {0}".format( self._identifier, listed([component.name for component in components]))) for component in components: self._server.TestCase.add_component(self.id, component.id)
def _fetch(self, inset=None): """ Fetch currently linked test cases from the server """ # If data initialized from the inset ---> we're done if Container._fetch(self, inset): return # Fetch test cases from the server log.info("Fetching {0}'s cases".format(self._identifier)) injects = self._server.TestCase.filter({'plan': self.id}) log.data("Fetched {0}".format(listed(injects, "inject"))) self._current = set([TestCase(inject) for inject in injects]) self._original = set(self._current)
def remove(self, items): """ Remove an item or a list of items from the container """ # Convert to set representation if isinstance(items, list): items = set(items) else: items = set([items]) # If there are any items to be removed remove_items = items.intersection(self._items) if remove_items: log.info("Removing {0} from {1}'s {2}".format( listed([item.identifier for item in remove_items], self._class.__name__, max=10), self._object.identifier, self.__class__.__name__)) self._items.difference_update(items) if config.get_cache_level() != config.CACHE_NONE: self._modified = True else: self._update()
def add(self, items): """ Add an item or a list of items to the container """ # Convert to set representation if isinstance(items, list): items = set(items) else: items = set([items]) # If there are any new items add_items = items - self._items if add_items: log.info("Adding {0} to {1}'s {2}".format( listed([item.identifier for item in add_items], self._class.__name__, max=10), self._object.identifier, self.__class__.__name__)) self._items.update(items) if config.get_cache_level() != config.CACHE_NONE: self._modified = True else: self._update()
def __str__(self): return listed(self._items, quote="'")
def __str__(self): return listed(self._items)
def __str__(self): """ The list of linked components' names """ if self._items: return listed(sorted([component.name for component in self])) else: return "[None]"