예제 #1
0
    def test_is_phone_exten(self):
        self.add_user_line_with_exten(exten='445')
        self.add_user_line_with_exten(exten='221')
        self.assertFalse(user_line_dao.is_phone_exten('12345'))
        self.assertFalse(user_line_dao.is_phone_exten(None))

        self.add_user_line_with_exten(exten=LINE_NUMBER)

        self.assertTrue(user_line_dao.is_phone_exten(LINE_NUMBER))
예제 #2
0
    def test_is_phone_exten(self):
        self.add_user_line_with_exten(exten='445')
        self.add_user_line_with_exten(exten='221')
        self.assertFalse(user_line_dao.is_phone_exten('12345'))
        self.assertFalse(user_line_dao.is_phone_exten(None))

        self.add_user_line_with_exten(exten=LINE_NUMBER)

        self.assertTrue(user_line_dao.is_phone_exten(LINE_NUMBER))
예제 #3
0
    def on_cti_agent_login(self, user_id, agent_xid=None, agent_exten=None):
        agent_id = self._transform_agent_xid(user_id, agent_xid)
        if not agent_id:
            logger.info('%s not an agent (%s)', agent_xid, agent_exten)
            return 'error', {'error_string': 'agent_login_invalid_exten',
                             'class': 'ipbxcommand'}
        if not agent_exten:
            extens = self.find_agent_exten(agent_id)
            agent_exten = extens[0] if extens else None

        if not user_line_dao.is_phone_exten(agent_exten):
            logger.info('%s tried to login with wrong exten (%s)', agent_id, agent_exten)
            return 'error', {'error_string': 'agent_login_invalid_exten',
                             'class': 'ipbxcommand'}

        agent_context = agent_dao.agent_context(agent_id)
        try:
            self.login(agent_id, agent_exten, agent_context)
        except ExtensionInUseError:
            logger.warning('could not log agent %s on exten %s@%s: already in use',
                           agent_id, agent_exten, agent_context)
            return 'error', {'error_string': 'agent_login_exten_in_use',
                             'class': 'ipbxcommand'}
        except NoSuchExtensionError:
            logger.warning('could not log agent %s on exten %s@%s: no such extension',
                           agent_id, agent_exten, agent_context)
            return 'error', {'error_string': 'agent_login_invalid_exten',
                             'class': 'ipbxcommand'}
예제 #4
0
    def test_delete(self):
        usersip_id = 2
        self.add_usersip(id=usersip_id)
        line = self.add_line(number=LINE_NUMBER,
                             context='default',
                             protocol='sip',
                             protocolid=usersip_id)
        exten = self.add_extension(exten=LINE_NUMBER,
                                   context='default')

        line_dao.delete(line.id)

        self.assertFalse(user_line_dao.is_phone_exten(LINE_NUMBER))

        inserted_usersip = self.session.query(UserSIP).filter(UserSIP.id == usersip_id).first()
        self.assertEquals(None, inserted_usersip)
        inserted_extension = self.session.query(ExtensionSchema).filter(ExtensionSchema.id == exten.id).first()
        self.assertEquals(None, inserted_extension)