Exemple #1
0
    def test_dialed_extension_when_no_channel_exist(self):
        self.ari.channels.getChannelVar.side_effect = ARINotFound(
            original_error='no channel',
            ari_client=self.ari,
        )
        self.ari.channels.get.side_effect = ARINotFound(
            original_error='no channel',
            ari_client=self.ari,
        )

        channel = Channel(s.channel_id, self.ari)
        result = channel.dialed_extension()

        assert_that(result, equal_to(None))
    def test_no_channel(self):
        self.ari.channels.get.side_effect = ARINotFound(
            s.ari_client, s.original_error)

        result = self.poller._channel_is_up(s.channel_id)

        assert_that(result, equal_to(False))
    def test_no_channel(self):
        self.ari.channels.getChannelVar.side_effect = ARINotFound(
            s.ari_client, s.original_error)

        result = self.poller._get_contacts(self.channel_id, self.aor)

        assert_that(result, empty())
    def test_given_no_calls_when_get_unknown_channel_then_raise_keyerror(self):
        self.ari.asterisk.getGlobalVar.side_effect = ARINotFound(
            Mock(), Mock())

        assert_that(
            calling(self.persistor.get).with_args('unknown-channel-id'),
            raises(KeyError))
Exemple #5
0
    def test_dialed_extension_when_dialing_right_into_stasis(self):
        self.ari.channels.getChannelVar.side_effect = ARINotFound(
            original_error='no var',
            ari_client=self.ari,
        )
        self.ari.channels.get.return_value = mocked_channel = Mock()
        mocked_channel.json = {'dialplan': {'exten': s.exten}}

        channel = Channel(s.channel_id, self.ari)
        result = channel.dialed_extension()

        assert_that(result, equal_to(s.exten))
Exemple #6
0
    def test_connect_event_originator_wrong_originator(self):
        event = {
            'application': 'myapp',
            'args': ['red', 'dialed_from', 'channel-id']
        }
        ari = Mock()
        ari.channels.get.side_effect = ARINotFound(Mock(), Mock())

        assert_that(calling(ConnectCallEvent).with_args(channel=Mock(),
                                                        event=event,
                                                        ari=ari,
                                                        state_persistor=Mock()),
                    raises(InvalidConnectCallEvent))
    def test_that_hungup_channels_do_not_interrupt(self):
        channel_1 = Mock()
        channel_1.get.side_effect = ARINotFound(s.ari_client, s.original_error)

        channel_2 = Mock()
        channel_2.id = s.channel_2_id
        channel_2.get.return_value = Mock(json={'state': 'Ringing'})

        self.poller._dialed_channels = [channel_1, channel_2]

        self.poller._remove_unanswered_channels()

        self.ari.channels.hangup.assert_called_once_with(
            channelId=s.channel_2_id)
Exemple #8
0
def get_bridge_variable(ari, bridge_id, variable):
    global_variable = 'XIVO_BRIDGE_VARIABLES_{}'.format(bridge_id)
    try:
        cache_str = ari.asterisk.getGlobalVar(variable=global_variable)['value']
    except ARINotFound:
        cache_str = '{}'
    if not cache_str:
        cache_str = '{}'
    cache = json.loads(cache_str)

    try:
        return cache[variable]
    except KeyError as e:
        raise ARINotFound(ari, e)
 def hangup_mock(channelId):
     if channelId == s.channel_1_id:
         raise ARINotFound(s.ari_client, s.original_error)