Beispiel #1
0
    def test_is_agent(self, mock_is_agent_member_name):
        queue_name = 'queue1'
        member_name = 'Agent/1234'
        mock_is_agent_member_name.return_value = True

        queue_member = QueueMember(queue_name, member_name, None)
        result = queue_member.is_agent()

        mock_is_agent_member_name.assert_called_once_with(member_name)
        self.assertEqual(result, True)
Beispiel #2
0
    def test_to_cti_status(self):
        queue_name = 'queue1'
        member_name = 'Agent/1234'
        state = Mock()

        queue_member = QueueMember(queue_name, member_name, state)
        result = queue_member.to_cti_status()

        expected_result = {
            'queue_name': queue_name,
            'interface': member_name,
            'membership': 'static'
        }
        self.assertEqual(result, expected_result)
        state._to_cti.assert_called_once_with(expected_result)
Beispiel #3
0
    def _add_dao_queue_members_on_update(self):
        old_queue_member_ids = set(
            self._queue_member_manager.get_queue_members_id())
        new_queue_member_ids = set()
        add_queue_members = []

        with session_scope():
            for dao_queue_member in queue_member_dao.get_queue_members_for_queues(
            ):
                queue_name = dao_queue_member.queue_name
                member_name = dao_queue_member.member_name
                queue_member_id = format_queue_member_id(
                    queue_name, member_name)
                new_queue_member_ids.add(queue_member_id)
                if queue_member_id not in old_queue_member_ids:
                    queue_member = QueueMember.from_dao_queue_member(
                        dao_queue_member)
                    add_queue_members.append(queue_member)

        for queue_member in add_queue_members:
            self._queue_member_manager._add_queue_member(queue_member)
            self._ask_member_queue_status(queue_member)

        obsolete_queue_member_ids = old_queue_member_ids - new_queue_member_ids
        return obsolete_queue_member_ids
Beispiel #4
0
 def _add_dao_queue_members_on_init(self):
     with session_scope():
         queue_members = [
             QueueMember.from_dao_queue_member(row)
             for row in queue_member_dao.get_queue_members_for_queues()
         ]
     for queue_member in queue_members:
         self._queue_member_manager._add_queue_member(queue_member)
Beispiel #5
0
    def test_id_on_initialisation(self, mock_format_queue_member_id):
        queue_name = 'queue1'
        member_name = 'Agent/1234'
        mock_format_queue_member_id.return_value = 'something'

        queue_member = QueueMember(queue_name, member_name, None)

        mock_format_queue_member_id.assert_called_once_with(queue_name, member_name)
        self.assertEqual(queue_member.id, 'something')
Beispiel #6
0
 def _add_dao_queue_members_on_update(self):
     old_queue_member_ids = set(self._queue_member_manager.get_queue_members_id())
     new_queue_member_ids = set()
     for dao_queue_member in queue_member_dao.get_queue_members_for_queues():
         queue_name = dao_queue_member.queue_name
         member_name = dao_queue_member.member_name
         queue_member_id = format_queue_member_id(queue_name, member_name)
         new_queue_member_ids.add(queue_member_id)
         if queue_member_id not in old_queue_member_ids:
             queue_member = QueueMember.from_dao_queue_member(dao_queue_member)
             self._queue_member_manager._add_queue_member(queue_member)
             self._ask_member_queue_status(queue_member)
     obsolete_queue_member_ids = old_queue_member_ids - new_queue_member_ids
     return obsolete_queue_member_ids
Beispiel #7
0
 def on_ami_agent_added_to_queue(self, ami_event):
     queue_name = ami_event['QueueName']
     agent_number = ami_event['AgentNumber']
     queue_member = QueueMember.from_ami_agent_added_to_queue(
         queue_name, agent_number)
     self._queue_member_manager._add_queue_member(queue_member)
Beispiel #8
0
 def _add_dao_queue_members_on_init(self):
     for dao_queue_member in queue_member_dao.get_queue_members_for_queues(
     ):
         queue_member = QueueMember.from_dao_queue_member(dao_queue_member)
         self._queue_member_manager._add_queue_member(queue_member)
Beispiel #9
0
 def on_ami_agent_added_to_queue(self, ami_event):
     queue_name = ami_event['QueueName']
     agent_number = ami_event['AgentNumber']
     queue_member = QueueMember.from_ami_agent_added_to_queue(queue_name, agent_number)
     self._queue_member_manager._add_queue_member(queue_member)
Beispiel #10
0
 def _add_dao_queue_members_on_init(self):
     for dao_queue_member in queue_member_dao.get_queue_members_for_queues():
         queue_member = QueueMember.from_dao_queue_member(dao_queue_member)
         self._queue_member_manager._add_queue_member(queue_member)