예제 #1
0
    def test_get_extension_from_local_channel(self):
        channel = 'Local/id-5@agentcallback-38974358734;2'
        expected_extension = Extension('', '', False)

        result = helper.get_extension_from_channel(channel)

        self.assertEquals(expected_extension, result)
예제 #2
0
 def _add_channel(self, channel_source, channel_destination, uniqueid,
                  destination_uniqueid):
     try:
         extension_source = helper.get_extension_from_channel(
             channel_source)
         extension_destination = helper.get_extension_from_channel(
             channel_destination)
     except (InvalidChannelError) as e:
         logger.error(e)
     else:
         self._call_storage.new_call(
             uniqueid,
             destination_uniqueid,
             _Channel(extension_source, channel_source),
             _Channel(extension_destination, channel_destination),
         )
예제 #3
0
 def _update_channel_status(self, channel, status):
     try:
         extension = helper.get_extension_from_channel(channel)
     except (InvalidChannelError) as e:
         logger.error(e)
     else:
         self._call_storage.update_endpoint_status(extension, status)
예제 #4
0
    def test_get_extension_from_local_channel(self):
        channel = 'Local/id-5@agentcallback-38974358734;2'
        expected_extension = Extension('', '', False)

        result = helper.get_extension_from_channel(channel)

        self.assertEquals(expected_extension, result)
예제 #5
0
    def test_get_extension_from_channel_no_extension(self, dao_get_extension):
        channel = 'SIP/asdlkfj-532486'
        dao_get_extension.side_effect = LookupError
        expected_result = Extension(number='', context='', is_internal=False)

        result = helper.get_extension_from_channel(channel)

        self.assertEquals(expected_result, result)
예제 #6
0
    def test_get_extension_from_channel_no_extension(self, dao_get_extension):
        channel = 'SIP/asdlkfj-532486'
        dao_get_extension.side_effect = LookupError
        expected_result = Extension(number='', context='', is_internal=False)

        result = helper.get_extension_from_channel(channel)

        self.assertEquals(expected_result, result)
예제 #7
0
    def test_get_extension_from_channel(self, dao_get_extension):
        channel = 'SIP/asdlkfj-532486'
        expected_extension = Mock()
        dao_get_extension.return_value = expected_extension

        result = helper.get_extension_from_channel(channel)

        dao_get_extension.assert_called_once_with('SIP', 'asdlkfj')
        self.assertEquals(expected_extension, result)
예제 #8
0
    def test_get_extension_from_channel(self, dao_get_extension):
        channel = 'SIP/asdlkfj-532486'
        expected_extension = Mock()
        dao_get_extension.return_value = expected_extension

        result = helper.get_extension_from_channel(channel)

        dao_get_extension.assert_called_once_with('SIP', 'asdlkfj')
        self.assertEquals(expected_extension, result)
예제 #9
0
    def handle_new_channel(self, event):
        try:
            channel = event['Channel']
            unique_id = event['Uniqueid']
            source_exten = helper.get_extension_from_channel(channel)
        except (InvalidChannelError, KeyError):
            logger.debug('ignoring %s', event)
            return

        self._call_storage.new_call(
            unique_id,
            '',
            _Channel(source_exten, channel),
            _Channel(Extension('', '', True), ''),
        )