示例#1
0
    def get_relations(self, user_id):
        logger.debug('User %s is requesting his relations', user_id)
        xuserid = 'xivo/{user_id}'.format(user_id=user_id)
        try:
            line_id = dao.user.get_line(user_id)['id']
        except NoSuchLineException:
            line_id = None
        agent_id = dao.user.get_agent_id(user_id)

        msg = CTIMessageFormatter.relations(self._uuid, user_id, line_id, agent_id)

        self._cti_server.send_to_cti_client(xuserid, msg)
    def test_relations_no_endpoint_no_agent(self):
        xivo_uuid = 'my-xivo-uuid'
        user_id = '42'

        result = CTIMessageFormatter.relations(xivo_uuid, user_id, None, None)

        assert_that(
            result,
            equal_to({
                'class': 'relations',
                'data': {
                    'xivo_uuid': xivo_uuid,
                    'user_id': 42,
                    'endpoint_id': None,
                    'agent_id': None
                }
            }))
    def test_relations(self):
        xivo_uuid = 'my-xivo-uuid'
        user_id = '42'
        endpoint_id = '50'
        agent_id = '24'

        result = CTIMessageFormatter.relations(xivo_uuid, user_id, endpoint_id,
                                               agent_id)

        assert_that(
            result,
            equal_to({
                'class': 'relations',
                'data': {
                    'xivo_uuid': xivo_uuid,
                    'user_id': 42,
                    'endpoint_id': 50,
                    'agent_id': 24
                }
            }))