def test_from_dao_queue_member(self): dao_queue_member = Mock() dao_queue_member.penalty = 1 expected_state = QueueMemberState() expected_state.penalty = 1 state = QueueMemberState.from_dao_queue_member(dao_queue_member) self.assertEqual(state, expected_state)
def test_copy(self): state1 = QueueMemberState() state1.calls_taken = 42 state2 = state1.copy() state2.interface = 'Local/423232@foobar' self.assertEqual(state1.calls_taken, state2.calls_taken) self.assertNotEqual(state1.interface, state2.interface) self.assertTrue(state1.__dict__ is not state2.__dict__)
def test_to_cti(self): state = QueueMemberState() state.status = '123' result = {} expected_result = { 'callstaken': '0', 'paused': '0', 'penalty': '0', 'status': '123', 'lastcall': '', } state._to_cti(result) self.assertEqual(result, expected_result)
def on_ami_queue_member_status(self, ami_event): queue_name = ami_event['Queue'] member_name = ami_event['MemberName'] queue_member = self._queue_member_manager.get_queue_member_by_name(queue_name, member_name) if queue_member is not None: new_state = QueueMemberState.from_ami_queue_member_status(ami_event) self._queue_member_manager._update_queue_member(queue_member, new_state)
def on_ami_queue_member(self, ami_event): queue_name = ami_event['Queue'] member_name = ami_event['Name'] queue_member = self._queue_member_manager.get_queue_member_by_name( queue_name, member_name) if queue_member is not None: new_state = QueueMemberState.from_ami_queue_member(ami_event) self._queue_member_manager._update_queue_member( queue_member, new_state)
def on_ami_queue_member_added(self, ami_event): queue_name = ami_event['Queue'] member_name = ami_event['MemberName'] queue_member = self._queue_member_manager.get_queue_member_by_name(queue_name, member_name) if queue_member is None: self._log_unknown_queue_member('added', queue_name, member_name) else: if not queue_member.is_agent(): logger.info('ignoring queue member added event for %r: not an agent', queue_member.id) else: new_state = QueueMemberState.from_ami_queue_member_added(ami_event) self._queue_member_manager._update_queue_member(queue_member, new_state)
def on_ami_queue_member_added(self, ami_event): queue_name = ami_event['Queue'] member_name = ami_event['MemberName'] queue_member = self._queue_member_manager.get_queue_member_by_name( queue_name, member_name) if queue_member is None: self._log_unknown_queue_member('added', queue_name, member_name) else: if not queue_member.is_agent(): logger.info( 'ignoring queue member added event for %r: not an agent', queue_member.id) else: new_state = QueueMemberState.from_ami_queue_member_added( ami_event) self._queue_member_manager._update_queue_member( queue_member, new_state)
def test_from_ami_queue_member_added(self): ami_event = { 'Queue': 'foobar', 'Location': 'SIP/abcdef', 'MemberName': 'Agent/2', 'Membership': 'dynamic', 'Penalty': '1', 'CallsTaken': '42', 'LastCall': '1355154813', 'Status': '1', 'Paused': '1', } expected_state = QueueMemberState() expected_state.calls_taken = 42 expected_state.interface = 'SIP/abcdef' expected_state.last_call = datetime.fromtimestamp(1355154813) expected_state.paused = True expected_state.penalty = 1 expected_state.status = '1' state = QueueMemberState.from_ami_queue_member_added(ami_event) self.assertEqual(state, expected_state)
def test_equal(self): state1 = QueueMemberState() state2 = QueueMemberState() self.assertEqual(state1, state2)
def test_not_equal(self): state1 = QueueMemberState() state1.calls_taken += 1 state2 = QueueMemberState() self.assertNotEqual(state1, state2)