Пример #1
0
 def test_validate_edit_agent_queue_association_no_such_agent(
         self, _, __, patch_get_agent):
     patch_get_agent.return_value = None
     queue_member = QueueMemberAgent(agent_id=3, queue_id=5, penalty=3)
     self.assertRaises(NotFoundError,
                       validator.validate_edit_agent_queue_association,
                       queue_member)
Пример #2
0
 def test_validate_edit_agent_queue_association_no_such_association(
         self, patch_get_by_queue_and_agent, _, __):
     patch_get_by_queue_and_agent.side_effect = NotFoundError
     queue_member = QueueMemberAgent(agent_id=3, queue_id=5, penalty=3)
     self.assertRaises(NotFoundError,
                       validator.validate_edit_agent_queue_association,
                       queue_member)
Пример #3
0
    def test_validate_edit_agent_queue_association(
            self, patch_get_by_queue_and_agent, patch_get_queue, _):
        queue_member = QueueMemberAgent(agent_id=3, queue_id=5, penalty=3)
        validator.validate_edit_agent_queue_association(queue_member)

        patch_get_queue.assert_called_once_with(queue_member.queue_id)
        patch_get_by_queue_and_agent.assert_called_once_with(
            queue_member.queue_id, queue_member.agent_id)
Пример #4
0
    def test_remove_agent_from_queue(self):
        queue_member = QueueMemberAgent(agent_id=31, queue_id=7)

        self.service.dissociate(queue_member)

        self.validator.validate_remove_agent_from_queue.assert_called_once_with(
            queue_member.agent_id, queue_member.queue_id)
        self.dao.remove_agent_from_queue.assert_called_once_with(
            queue_member.agent_id, queue_member.queue_id)
        self.notifier.agent_removed_from_queue.assert_called_once_with(
            queue_member.agent_id, queue_member.queue_id)
Пример #5
0
    def test_edit_agent_queue_association(self):
        queue_member = QueueMemberAgent(agent_id=12, queue_id=2, penalty=4)

        self.service.edit(queue_member)

        self.validator.validate_edit_agent_queue_association.assert_called_once_with(
            queue_member)
        self.dao.edit_agent_queue_association.assert_called_once_with(
            queue_member)
        self.notifier.agent_queue_association_updated.assert_called_once_with(
            queue_member)
Пример #6
0
    def test_associate_agent_to_queue(self):
        queue_member = QueueMemberAgent(agent_id=31, queue_id=7, penalty=3)
        self.dao.associate.return_value = queue_member

        qm = self.service.associate(queue_member)

        self.validator.validate_associate_agent_queue.assert_called_once_with(
            queue_member.queue_id, queue_member.agent_id)
        self.dao.associate.assert_called_once_with(queue_member)
        self.notifier.agent_queue_associated.assert_called_once_with(
            queue_member)
        assert_that(qm, equal_to(queue_member))
Пример #7
0
    def test_get_by_queue_id_and_agent_id(self):
        agent_id = 3
        queue_id = 2
        queue_member = self.dao.get_by_queue_id_and_agent_id.return_value = QueueMemberAgent(
            agent_id=agent_id, queue_id=queue_id, penalty=5)

        result = self.service.get(queue_id, agent_id)

        self.validator.validate_get_agent_queue_association.assert_called_once_with(
            queue_id, agent_id)
        self.dao.get_by_queue_id_and_agent_id.assert_called_once_with(
            queue_id, agent_id)
        assert_that(result, equal_to(queue_member))
Пример #8
0
    def test_edited(self, send_bus_event, AgentQueueAssociationEditedEvent,
                    exec_request_handler):
        new_event = AgentQueueAssociationEditedEvent.return_value = Mock()
        queue_member = QueueMemberAgent(queue_id=2, agent_id=30, penalty=5)
        self.sysconfd_command['agentbus'] = [
            'agent.edit.%s' % queue_member.agent_id
        ]

        notifier.agent_queue_association_updated(queue_member)

        AgentQueueAssociationEditedEvent.assert_called_once_with(
            queue_member.queue_id, queue_member.agent_id, queue_member.penalty)
        send_bus_event.assert_called_once_with(new_event,
                                               new_event.routing_key)
        exec_request_handler.assert_called_once_with(self.sysconfd_command)