Beispiel #1
0
class TestApplication(TestCase):
    """Run tests on the `Application` class."""
    def setUp(self):
        """Setup some default variables for test usage."""
        self.a = Application('application', 'data')

    def test_attrs_stick(self):
        """Ensure attributes stick."""
        self.assertEqual(self.a.application, 'application')
        self.assertEqual(self.a.data, 'data')

    def test_render_valid_application(self):
        """Ensure `render` works using a valid `application` attribute."""
        self.assertTrue('application' in ''.join(self.a.render()))

    def test_str_valid_data(self):
        """Ensure `render` works using a valid `data` attribute."""
        self.assertTrue('data' in ''.join(self.a.render()))
Beispiel #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'
Beispiel #3
0
class TestApplication(TestCase):
	"""Run tests on the `Application` class."""

	def setUp(self):
		"""Setup some default variables for test usage."""
		self.a = Application('application', 'data')

	def test_attrs_stick(self):
		"""Ensure attributes stick."""
		eq_(self.a.application, 'application')
		eq_(self.a.data, 'data')

	def test_render_valid_application(self):
		"""Ensure `render` works using a valid `application` attribute."""
		ok_('application' in ''.join(self.a.render()))

	def test_str_valid_data(self):
		"""Ensure `render` works using a valid `data` attribute."""
		ok_('data' in ''.join(self.a.render()))
Beispiel #4
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()
Beispiel #5
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"
Beispiel #6
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()
Beispiel #7
0
from pycall import CallFile, Call, Application

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

c = CallFile(call, action)
c.spool()
Beispiel #8
0
def call(number, time=None):
    c = Call('SIP/flowroute/%s' % number)
    a = Application('Playback', 'hello-world')
    cf = CallFile(c, a)
    cf.spool(time)
Beispiel #9
0
 def setUp(self):
     """Setup some default variables for test usage."""
     self.call = Call('channel')
     self.action = Application('application', 'data')
     self.spool_dir = '/tmp'
Beispiel #10
0
	def setUp(self):
		"""Setup some default variables for test usage."""
		self.a = Application('application', 'data')
Beispiel #11
0
 def setUp(self):
     """Setup some default variables for test usage."""
     self.a = Application('application', 'data')