Esempio n. 1
0
 def test_attrs_stick(self):
     """Ensure attributes stick."""
     c = Call('channel', 'callerid', 'variables', 'account', 0, 1, 2)
     eq_(c.channel, 'channel')
     eq_(c.callerid, 'callerid')
     eq_(c.variables, 'variables')
     eq_(c.account, 'account')
     eq_(c.wait_time, 0)
     eq_(c.retry_time, 1)
     eq_(c.max_retries, 2)
Esempio n. 2
0
def dialout():
    call_from = request.args.get('from', '')
    call_to = request.args.get('to', '')
    cfrom = 'SIP/{}@hotvoip'.format(call_from)
    cto = 'SIP/{}@hotvoip'.format(call_to)
    c = Call(cfrom)
    a = Application('Dial', cto)
    cf = CallFile(c, a)
    cf.spool()
    return 'dialed'
Esempio n. 3
0
def call(target, callid, sound):

    CallFile(
        Call('SIP/flowroute/{}'.format(target), callerid=callid),
        Application(
            'Playback',
            sound  # supports many different types of audio files
        ),
        user=
        '******'  # assuming asterisk is running as its own user (recommended)
    ).spool()
Esempio n. 4
0
def localcall():
    call_from = request.args.get('from', '')
    call_to = request.args.get('to', '')
    if call_from and call_to:
        cfrom = 'SIP/{}'.format(call_from)
        logging.debug(cfrom)
        cto = 'SIP/{}'.format(call_to)
        logging.debug(cto)
        c = Call(cfrom)
        a = Application('Dial', cto)
        cf = CallFile(c, a)
        cf.spool()
    else:
        return "no call made"
    return "call made"
Esempio n. 5
0
    def send_command(self, action: str, access_code: str) -> None:
        """ Send control sequence via Asterisk call file """

        call = Call(f"SIP/{self.extension}",
                    wait_time=self.wait_time,
                    retry_time=self.retry_time,
                    max_retries=self.max_retries)

        seq = self._build_dtmf_sequence(action, access_code)

        logger.debug("Sending action '%s' (DTMF: '%s') to alarm", action, seq)

        action = Application("SendDTMF", seq)

        callfile_args = {"archive": True, "spool_dir": self.spool_dir}
        if self.asterisk_user:
            callfile_args["user"] = self.asterisk_user

        c = CallFile(call, action, **callfile_args)
        c.spool()
Esempio n. 6
0
 def test_render_valid_account(self):
     """Ensure `render` works using a valid `account` attribute."""
     c = Call('channel', account='account')
     self.assertTrue('account' in ''.join(c.render()))
Esempio n. 7
0
 def test_render_valid_callerid(self):
     """Ensure `render` works using a valid `callerid` attribute."""
     c = Call('channel', callerid='callerid')
     self.assertTrue('callerid' in ''.join(c.render()))
Esempio n. 8
0
 def test_is_valid_invalid_retry_time(self):
     """Ensure `is_valid` fails given an invalid `retry_time` attribute."""
     c = Call('channel', retry_time='1')
     self.assertFalse(c.is_valid())
Esempio n. 9
0
 def test_is_valid_valid_max_retries(self):
     """Ensure `is_valid` works using a valid `max_retries` attribute."""
     c = Call('channel', max_retries=2)
     self.assertTrue(c.is_valid())
Esempio n. 10
0
 def test_is_valid_valid_wait_time(self):
     """Ensure `is_valid` works using a valid `wait_time` attribute."""
     c = Call('channel', wait_time=0)
     self.assertTrue(c.is_valid())
Esempio n. 11
0
def call(number, time=None):
    c = Call('SIP/flowroute/%s' % number)
    a = Application('Playback', 'hello-world')
    cf = CallFile(c, a)
    cf.spool(time)
Esempio n. 12
0
 def test_is_valid_invalid_call_is_valid(self):
     """Ensure `is_valid` fails when `call.is_valid()` fails."""
     c = CallFile(Call('channel', wait_time='10'),
                  self.action,
                  spool_dir=self.spool_dir)
     assert_false(c.is_valid())
Esempio n. 13
0
 def test_is_valid_valid_max_retries(self):
     """Ensure `is_valid` works using a valid `max_retries` attribute."""
     c = Call('channel', max_retries=2)
     ok_(c.is_valid())
Esempio n. 14
0
 def test_is_valid_valid_retry_time(self):
     """Ensure `is_valid` works using a valid `retry_time` attribute."""
     c = Call('channel', retry_time=1)
     ok_(c.is_valid())
Esempio n. 15
0
 def test_is_valid_valid_wait_time(self):
     """Ensure `is_valid` works using a valid `wait_time` attribute."""
     c = Call('channel', wait_time=0)
     ok_(c.is_valid())
Esempio n. 16
0
 def test_is_valid_valid_variables(self):
     """Ensure `is_valid` works using a valid `variables` attribute."""
     c = Call('channel', variables={'a': 'b'})
     ok_(c.is_valid())
Esempio n. 17
0
 def test_is_valid_invalid_wait_time(self):
     """Ensure `is_valid` fails given an invalid `wait_time` attribute."""
     c = Call('channel', wait_time='0')
     self.assertFalse(c.is_valid())
Esempio n. 18
0
 def test_render_valid_retry_time(self):
     """Ensure `render` works using a valid `retry_time` attribute."""
     c = Call('channel', retry_time=1)
     self.assertTrue('1' in ''.join(c.render()))
Esempio n. 19
0
 def test_is_valid_invalid_variables(self):
     """Ensure `is_valid` fails given an invalid `variables` attribute."""
     c = Call('channel', variables='ab')
     assert_false(c.is_valid())
Esempio n. 20
0
 def test_render_no_attrs(self):
     """Ensure `render` works with no optional attributes specified."""
     c = Call('local/18882223333@outgoing')
     self.assertTrue('Channel: local/18882223333@outgoing' in ''.join(c.render()))
Esempio n. 21
0
 def test_is_valid_invalid_retry_time(self):
     """Ensure `is_valid` fails given an invalid `retry_time` attribute."""
     c = Call('channel', retry_time='1')
     assert_false(c.is_valid())
Esempio n. 22
0
 def test_render_no_attrs(self):
     """Ensure `render` works with no optional attributes specified."""
     c = Call('local/18882223333@outgoing')
     ok_('Channel: local/18882223333@outgoing' in ''.join(c.render()))
Esempio n. 23
0
 def test_is_valid_invalid_max_retries(self):
     """Ensure `is_valid` fails given an invalid `max_retries` attribute."""
     c = Call('channel', max_retries='2')
     assert_false(c.is_valid())
Esempio n. 24
0
 def test_is_valid_valid_variables(self):
     """Ensure `is_valid` works using a valid `variables` attribute."""
     c = Call('channel', variables={'a': 'b'})
     self.assertTrue(c.is_valid())
Esempio n. 25
0
 def test_render_valid_channel(self):
     """Ensure `render` works using a valid `channel` attribute."""
     c = Call('channel')
     ok_('channel' in ''.join(c.render()))
Esempio n. 26
0
 def test_is_valid_valid_retry_time(self):
     """Ensure `is_valid` works using a valid `retry_time` attribute."""
     c = Call('channel', retry_time=1)
     self.assertTrue(c.is_valid())
Esempio n. 27
0
 def test_render_valid_callerid(self):
     """Ensure `render` works using a valid `callerid` attribute."""
     c = Call('channel', callerid='callerid')
     ok_('callerid' in ''.join(c.render()))
Esempio n. 28
0
 def test_is_valid_invalid_variables(self):
     """Ensure `is_valid` fails given an invalid `variables` attribute."""
     c = Call('channel', variables='ab')
     self.assertFalse(c.is_valid())
Esempio n. 29
0
 def test_render_valid_variables(self):
     """Ensure `render` works using a valid `variables` attribute."""
     c = Call('channel', variables={'a': 'b'})
     ok_('a=b' in ''.join(c.render()))
Esempio n. 30
0
 def test_is_valid_invalid_max_retries(self):
     """Ensure `is_valid` fails given an invalid `max_retries` attribute."""
     c = Call('channel', max_retries='2')
     self.assertFalse(c.is_valid())
Esempio n. 31
0
 def test_render_valid_account(self):
     """Ensure `render` works using a valid `account` attribute."""
     c = Call('channel', account='account')
     ok_('account' in ''.join(c.render()))
Esempio n. 32
0
 def test_render_valid_variables(self):
     """Ensure `render` works using a valid `variables` attribute."""
     c = Call('channel', variables={'a': 'b'})
     self.assertTrue('a=b' in ''.join(c.render()))
Esempio n. 33
0
	def test_render_valid_channel(self):
		"""Ensure `render` works using a valid `channel` attribute."""
		c = Call('channel')
		ok_('channel' in ''.join(c.render()))
Esempio n. 34
0
 def test_render_valid_wait_time(self):
     """Ensure `render` works using a valid `wait_time` attribute."""
     c = Call('channel', wait_time=0)
     self.assertTrue('0' in ''.join(c.render()))
Esempio n. 35
0
	def test_is_valid_invalid_wait_time(self):
		"""Ensure `is_valid` fails given an invalid `wait_time` attribute."""
		c = Call('channel', wait_time='0')
		assert_false(c.is_valid())
Esempio n. 36
0
 def test_render_valid_max_retries(self):
     """Ensure `render` works using a valid `max_retries` attribute."""
     c = Call('channel', max_retries=2)
     self.assertTrue('2' in ''.join(c.render()))
Esempio n. 37
0
 def test_render_valid_max_retries(self):
     """Ensure `render` works using a valid `max_retries` attribute."""
     c = Call('channel', max_retries=2)
     ok_('2' in ''.join(c.render()))
Esempio n. 38
0
 def test_render_valid_wait_time(self):
     """Ensure `render` works using a valid `wait_time` attribute."""
     c = Call('channel', wait_time=0)
     ok_('0' in ''.join(c.render()))
Esempio n. 39
0
 def setUp(self):
     """Setup some default variables for test usage."""
     self.call = Call('channel')
     self.action = Application('application', 'data')
     self.spool_dir = '/tmp'
Esempio n. 40
0
from pycall import CallFile, Call, Application

call = Call('SIP/flowroute/89257651079')
action = Application('Playback', 'hello-world')

c = CallFile(call, action)
c.spool()
Esempio n. 41
0
 def test_render_valid_retry_time(self):
     """Ensure `render` works using a valid `retry_time` attribute."""
     c = Call('channel', retry_time=1)
     ok_('1' in ''.join(c.render()))