Ejemplo n.º 1
0
def createRW(sub):
    logger.debug(('FUNC:::::: app.route.createRW           {0}').format(request.method))
    c_sub = ims.remoteWorker(sub)
    result = c_sub.subscriberCreate(session)
    if result.status_code == 500: #Successful EMA connection but there is an error.
        if result.text.find('Invalid Session') != -1:
            logger.debug(('** Leaving FUNC:::: app.route.createRW:  Invalid Session'))
            return redirect(url_for('auth.login', error='Invalid Session'))
        elif result.text.find('already exists') != -1: # -1 means does not exist, therefore if True it exists.
            logger.debug(('** Leaving FUNC:::: app.route.createRW:  Subscriber Already Exists'))
            session['mesg'] = 'ExistingSubscriber'
            return redirect(url_for('main.subscribers'))
        elif result.text.find('Public Id must be SIP URI or TEL URL') != -1 or result.text.find('<ema:respCode>35012</ema:respCode>') != -1: # -1 means does not exist, therefore if True it exists.
            logger.debug('Subscription Not Created due to + missing or related error')
            flash ('Error')
            flash ('The Subscription Number did not start with a +')
            flash ('Please try again.....')
            session['mesg'] = 'No Plus'
            return redirect(url_for('main.subscribers'))
        else:
            logger.debug('Unknown Error in createRW func')
            flash('Unknown Error in createRW func')
            return redirect(url_for('main.subscribers'))
            
    elif result.status_code == 200:
        session['mesg'] = 'Created'
        session['sub'] = sub
        session['sub_pw'] = c_sub.password
        del c_sub # Remove Subscriber Class instance
        logger.debug('** Leaving FUNC::::::: app.route.createRW')
        return redirect(url_for('main.subscribers'))
    else:
        logger.debug(('** Leaving FUNC::::::: app.route.createRW :::  Unknown Condition ::  {0}').format(result.status_code))
        flash ('Unknown error Condition  Create RW')
        return redirect(url_for('auth.login', error='Unknown error Condition'))
Ejemplo n.º 2
0
 def test_is_ims_sub_activities(self):
     """ test is to return True if IMS sub is created. """
     emaSession = ema_functions.emaLogin()
     session = {}
     session['emaSession'] = emaSession
     sub1 = class_ims_ema.remoteWorker('+353760000001')
     test1 = sub1.subscriberCreate(session)
     test2 = sub1.subscriberGet(session)
     test3 = sub1.subscriberDelete(session)
     test4 = sub1.subscriberGet(session)
     self.assertTrue(test1.status_code == 200 and test2.status_code == 200 and test3.status_code == 200 and test4.status_code == 500)