Beispiel #1
0
def getChannelByName(serviceName, channelName):
    db_getchannelbyname = getDbObject(serviceName)
    obj = db_getchannelbyname[CHANNELS_COLLECTION].find_one(
        {NAME: channelName})
    if obj is not None:
        return obj
    raise ChannelDoesNotExist()
Beispiel #2
0
def updateChannel(serviceName, channelId, name, json, acl):
    db_updatechannel = getDbObject(serviceName)
    try:
        obj = db_updatechannel[CHANNELS_COLLECTION].find_one(
            {ID: ObjectId(channelId)})
    except:
        raise ChannelDoesNotExist()
    if obj is None:
        raise ChannelDoesNotExist()
    else:
        obj['name'] = name
        if json is not None:
            obj['json'] = json
        if acl is not None:
            obj['acl'] = acl
        db_updatechannel[CHANNELS_COLLECTION].save(obj)
Beispiel #3
0
def getChannelById(serviceName, channelId):
    db_channelbyid = getDbObject(serviceName)
    if isinstance(channelId, str) or isinstance(channelId, unicode):
        obj = db_channelbyid[CHANNELS_COLLECTION].find_one(
            {'_id': ObjectId(channelId)})
    else:
        obj = db_channelbyid[CHANNELS_COLLECTION].find_one({'_id': channelId})
    if obj is not None:
        return obj
    raise ChannelDoesNotExist()
Beispiel #4
0
def deleteChannelById(serviceName, channelId):
    db_deletechannlebyid = getDbObject(serviceName)
    if isinstance(channelId, str) or isinstance(channelId, unicode):
        result = list(db_deletechannlebyid[CHANNELS_COLLECTION].find(
            {'_id': ObjectId(channelId)}))
    else:
        result = list(db_deletechannlebyid[CHANNELS_COLLECTION].find(
            {'_id': channelId}))
    if len(result) > 0:
        db_deletechannlebyid[CHANNELS_COLLECTION].remove(
            {'_id': ObjectId(channelId)})
    else:
        raise ChannelDoesNotExist()
Beispiel #5
0
 def testChannelDoesNotExistException(self):
     with self.assertRaises(ChannelDoesNotExist):
         raise ChannelDoesNotExist()