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)
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), )
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)
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)
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)
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), ''), )