Esempio n. 1
0
 def setUp(self):
     self.now = time.time()
     self._queue_entries = {
         '111.11': QueueEntry(1, 'Tester One', '1111', self.now + 10,
                              '111.11'),
         '222.22': QueueEntry(2, 'Tester Two', '2222', self.now + 7,
                              '222.22'),
         '333.33': QueueEntry(3, 'Tester Three', '3333', self.now + 1,
                              '333.33')
     }
     self._expected_queue_entry_list = [{
         'position': 1,
         'name': 'Tester One',
         'number': '1111',
         'join_time': self.now + 10,
         'uniqueid': '111.11'
     }, {
         'position': 2,
         'name': 'Tester Two',
         'number': '2222',
         'join_time': self.now + 7,
         'uniqueid': '222.22'
     }, {
         'position': 3,
         'name': 'Tester Three',
         'number': '3333',
         'join_time': self.now + 1,
         'uniqueid': '333.33'
     }]
    def test_update(self):
        expected = QueueEntry(1, CALLER_ID_NAME_1, CALLER_ID_NUMBER_1, JOIN_TIME_1 - WAIT_TIME_1, UNIQUE_ID_1)

        self.manager.insert(QUEUE_NAME, 1, CALLER_ID_NAME_1, CALLER_ID_NUMBER_1,
                            UNIQUE_ID_1, WAIT_TIME_1)

        entry = self.manager._queue_entries[QUEUE_NAME][UNIQUE_ID_1]

        self.assertEquals(entry, expected)
Esempio n. 3
0
    def test_encode_queue_entry(self):
        encoder = QueueEntryEncoder()
        q_entry = QueueEntry(1, 'Tester One', '1111', self.now + 10, '111.11')
        expected = {
            'position': 1,
            'name': 'Tester One',
            'number': '1111',
            'join_time': self.now + 10,
            'uniqueid': '111.11'
        }

        result = encoder._encode_queue_entry(q_entry)

        self.assertEqual(result, expected)
    def test_decrement_position(self):
        self.manager._queue_entries[QUEUE_NAME] = {}
        entries = self.manager._queue_entries[QUEUE_NAME]
        entries[1] = QueueEntry(1, 'one', '111', time.time(), '111.11')
        entries[2] = QueueEntry(2, 'two', '222', time.time(), '222.22')
        entries[3] = QueueEntry(3, 'three', '333', time.time(), '333.33')
        entries[4] = QueueEntry(4, 'four', '444', time.time(), '444.44')

        # 1 leaves the queue (pos 1)
        entries.pop(1)

        self.manager._decrement_position(QUEUE_NAME, 1)

        self.assertEqual(entries[2].position, 1)
        self.assertEqual(entries[3].position, 2)
        self.assertEqual(entries[4].position, 3)

        # 3 leaves the queue (pos 2)
        entries.pop(3)

        self.manager._decrement_position(QUEUE_NAME, 2)

        self.assertEqual(entries[2].position, 1)
        self.assertEqual(entries[4].position, 2)
WAIT_TIME_1 = 13

JOIN_MESSAGE_2 = {'Event': 'QueueCallerJoin',
                  'Privilege': 'call,all',
                  'Channel': 'SIP/my_trunk-1235',
                  'CallerIDNum': CALLER_ID_NUMBER_2,
                  'CallerIDName': CALLER_ID_NAME_2,
                  'ConnectedLineNum': 'unknown',
                  'ConnectedLineName': 'unknown',
                  'Queue': QUEUE_NAME,
                  'Position': '2',
                  'Count': '2',
                  'Uniqueid': UNIQUE_ID_2}

QUEUE_ENTRY_1 = QueueEntry(1, CALLER_ID_NAME_1, CALLER_ID_NUMBER_1, JOIN_TIME_1, UNIQUE_ID_1)
QUEUE_ENTRY_2 = QueueEntry(2, CALLER_ID_NAME_2, CALLER_ID_NUMBER_2, JOIN_TIME_2, UNIQUE_ID_2)

LEAVE_MESSAGE_1 = {'Event': 'QueueCallerLeave',
                   'Privilege': 'call,all',
                   'Channel': 'SIP/pcm_dev-0000001f',
                   'Queue': QUEUE_NAME,
                   'Count': '0',
                   'Position': '1',
                   'Uniqueid': UNIQUE_ID_1}


JOIN_MESSAGE_1 = {'Event': 'QueueCallerJoin',
                  'Privilege': 'call,all',
                  'Channel': 'SIP/my_trunk-1234',
                  'CallerIDNum': CALLER_ID_NUMBER_1,