예제 #1
0
    def test_linked_id(self):
        cel_events = [
            _new_cel(eventtype='CHAN_START', linkedid='2'),
            _new_cel(eventtype='HANGUP'),
            _new_cel(eventtype='CHAN_END')
        ]

        channel = CELChannel(cel_events)
        self.assertEqual('2', channel.linked_id())
예제 #2
0
    def test_exten_when_not_from_originate(self):
        cel_events = [
            _new_cel(eventtype='CHAN_START', exten=u'100'),
            _new_cel(eventtype='HANGUP'),
            _new_cel(eventtype='CHAN_END')
        ]

        channel = CELChannel(cel_events)
        self.assertEqual(u'100', channel.exten())
예제 #3
0
    def test_answer_duration_zero_when_not_answered(self):
        cel_events = [
            _new_cel(eventtype='CHAN_START'),
            _new_cel(eventtype='HANGUP'),
            _new_cel(eventtype='CHAN_END')
        ]

        channel = CELChannel(cel_events)
        self.assertEqual(0.0, channel.answer_duration())
예제 #4
0
    def test_channel_is_not_answered_when_not_answered(self):
        cel_events = [
            _new_cel(eventtype='CHAN_START'),
            _new_cel(eventtype='HANGUP'),
            _new_cel(eventtype='CHAN_END')
        ]

        channel = CELChannel(cel_events)
        self.assertFalse(channel.is_answered())
예제 #5
0
    def test_is_caller_false(self):
        cel_events = [
            _new_cel(eventtype='CHAN_START', uniqueid=u'2', linkedid=u'1'),
            _new_cel(eventtype='HANGUP'),
            _new_cel(eventtype='CHAN_END')
        ]

        cel_channel = CELChannel(cel_events)

        self.assertFalse(cel_channel.is_caller())
예제 #6
0
    def test_channel_start_time(self):
        datetime_gen = _new_datetime_generator()
        start_time = datetime_gen.next()
        cel_events = [
            _new_cel(eventtype='CHAN_START', eventtime=start_time),
            _new_cel(eventtype='HANGUP', eventtime=datetime_gen.next()),
            _new_cel(eventtype='CHAN_END', eventtime=datetime_gen.next())
        ]

        channel = CELChannel(cel_events)
        self.assertEqual(start_time, channel.channel_start_time())
예제 #7
0
    def test_answer_duration_when_answered(self):
        datetime_gen = _new_incr_datetime_generator()
        cel_events = [
            _new_cel(eventtype='CHAN_START', eventtime=datetime_gen.next()),
            _new_cel(eventtype='ANSWER', eventtime=datetime_gen.next()),
            _new_cel(eventtype='HANGUP', eventtime=datetime_gen.next()),
            _new_cel(eventtype='CHAN_END', eventtime=datetime_gen.next())
        ]

        channel = CELChannel(cel_events)
        self.assertEqual(2.0, channel.answer_duration())
예제 #8
0
    def test_is_originate(self):
        cel_events = [
            _new_cel(eventtype='CHAN_START', uniqueid=1, exten=u's'),
            _new_cel(eventtype='ANSWER', uniqueid=1),
            _new_cel(eventtype='APP_START', uniqueid=1),
            _new_cel(eventtype='CHAN_START', uniqueid=2),
            _new_cel(eventtype='ANSWER', uniqueid=2),
            _new_cel(eventtype='BRIDGE_START', uniqueid=1),
            _new_cel(eventtype='BRIDGE_END', uniqueid=1),
            _new_cel(eventtype='HANGUP', uniqueid=2),
            _new_cel(eventtype='CHAN_END', uniqueid=2),
            _new_cel(eventtype='HANGUP', uniqueid=1),
            _new_cel(eventtype='CHAN_END', uniqueid=1),
        ]

        cel_channel = CELChannel(cel_events)

        self.assertTrue(cel_channel.is_originate())

        cel_events = [
            _new_cel(eventtype='CHAN_START', uniqueid=1),
            _new_cel(eventtype='ANSWER', uniqueid=1),
            _new_cel(eventtype='APP_START', uniqueid=1),
            _new_cel(eventtype='CHAN_START', uniqueid=2),
            _new_cel(eventtype='ANSWER', uniqueid=2),
            _new_cel(eventtype='BRIDGE_START', uniqueid=1),
            _new_cel(eventtype='BRIDGE_END', uniqueid=1),
            _new_cel(eventtype='HANGUP', uniqueid=2),
            _new_cel(eventtype='CHAN_END', uniqueid=2),
            _new_cel(eventtype='HANGUP', uniqueid=1),
            _new_cel(eventtype='CHAN_END', uniqueid=1),
        ]

        cel_channel = CELChannel(cel_events)

        self.assertFalse(cel_channel.is_originate())
예제 #9
0
파일: cel_dao.py 프로젝트: jaunis/xivo-dao
def channel_by_unique_id(session, unique_id):
    cel_events = (session.query(CEL).filter(CEL.uniqueid == unique_id).all())
    if not cel_events:
        raise CELException('no such CEL event with uniqueid %s' % unique_id)
    else:
        return CELChannel(cel_events)