def addSpace(self, key, name, description=''): """Create a Space @param key: the key for the new space (must be unique) @param name: the space name @param description: the space description (default value is empty string) @rtype: dictionary @return: newly created Space""" missingMandatoryArgs = list() if not key: missingMandatoryArgs.append('key') if not name: missingMandatoryArgs.append('name') if missingMandatoryArgs: raise ValueError('missing mandatory argument %(args)s' % {'args': str(missingMandatoryArgs)}) space = Space.Space(key, name, description) try: spaceDict = self.server.addSpace(self.token, space.toDict()) except Exception, ex: self.logger.log(str(ex), 3) raise Exception('Unable to add space with key %s' % (space.key) + '. Reason %s' % Utils.extractDetails(ex))
def getSpace(self, key): """Return a Space object @param key: space key @rtype: Space""" return Space.create(self.pm_getSpaceManager().getSpace(key), self._modelDataManager)
def listSpaces(self): """Return a list of Spaces Objects available to the current user @rtype: Space list @return: list of available Spaces""" return tuple( Space.create(space, self._modelDataManager) for space in self.pm_getSpaceManager().listSpaces())
def editSpace(self, space): """Update modified changes to space @type space: Space object @param space: space @rtype: object @return: Space object""" return Space.create(self.pm_getSpaceManager().editSpace(space.toDict()),self._modelDataManager)
def addSpace(self, key, name, description = ''): """Create a Space @param key: the key for the new space (must be unique) @param name: the space name @param description: the space description (default value is empty string) @rtype: Space @return: newly added Space""" return Space.create(self.pm_getSpaceManager().addSpace(key, name, description),self._modelDataManager)
def editSpace(self, space): """Update modified changes to space @type space: Space object @param space: space @rtype: object @return: Space object""" return Space.create( self.pm_getSpaceManager().editSpace(space.toDict()), self._modelDataManager)
def addPersonalSpace(self, user ,title, description = ''): """Create a personal space to user @type user: string, or User object @param user: user name, or User object @param title: space title @param description: the space description (default value is empty string) @rtype: Space @return: newly created Space""" return Space.create(self.pm_getSpaceManager().addPersonalSpace(self._unbox(user) ,title, description),self._modelDataManager)
def addSpace(self, key, name, description=''): """Create a Space @param key: the key for the new space (must be unique) @param name: the space name @param description: the space description (default value is empty string) @rtype: Space @return: newly added Space""" return Space.create( self.pm_getSpaceManager().addSpace(key, name, description), self._modelDataManager)
def addPersonalSpace(self, user, title, description=''): """Create a personal space to user @type user: string, or User object @param user: user name, or User object @param title: space title @param description: the space description (default value is empty string) @rtype: Space @return: newly created Space""" return Space.create( self.pm_getSpaceManager().addPersonalSpace(self._unbox(user), title, description), self._modelDataManager)
def addPersonalSpace(self, userName, title, description=''): """Create a personal space to user @param userName: user name to create personal space for @param title: the space name @param description: the space description (default value is empty string) @rtype: dictionary @return: Space""" key = '' #the key is neglected and generated by confluence in this method, #the creation of Space object needs a key, so an empty string is used, #the space returned from confluence must have a key, # so this exceptional space object( space with empty string key) existance is limited to #this method namespace and is hidden from client code space = Space.Space(key, title, description) try: spaceDict = self._server.addPersonalSpace(self.token, space.toDict(), userName) except Exception, ex: self.logger.log(str(ex), 3) raise Exception('Unable to add personal space %s to user %s' % (title, userName) + '. Reason %s' % Utils.extractDetails(ex))
def listSpaces(self): """Return a list of Spaces Objects available to the current user @rtype: Space list @return: list of available Spaces""" return tuple(Space.create(space,self._modelDataManager) for space in self.pm_getSpaceManager().listSpaces())
def getSpace(self, key): """Return a Space object @param key: space key @rtype: Space""" return Space.create(self.pm_getSpaceManager().getSpace(key),self._modelDataManager)
def test_user_create_space(): space = Space.create(user1, space_name='铺西', descriptions='我们的家乡') assert user1 in space.moderators and space in user1.mod_spaces
def test_became_an_child_space(): s1 = Space('s1', '祁县') s2 = Space('s11', '铺西') s2.join_to(s1) s2.join_to(s1) assert {Space('s1', '铺西')} == s2.parents