Ejemplo n.º 1
0
 def ussd_session(self, modem, options):
     log.msg('Connecting to modem.')
     modem.verbose = options['verbose']
     yield modem.configure_modem()
     log.msg('Connected, starting console for: %s' % (options['code'],))
     console = USSDConsole(modem, on_exit=self.shutdown)
     stdio.StandardIO(console)
     log.msg('Dialing: %s' % (options['code'],))
     yield console.dial(options['code'])
Ejemplo n.º 2
0
Archivo: service.py Proyecto: smn/txgsm
 def ussd_session(self, modem, options):
     log.msg('Connecting to modem.')
     cmd_options = options.subOptions
     yield modem.configure_modem()
     log.msg('Connected, starting console for: %s' % (cmd_options['code'],))
     console = USSDConsole(modem, on_exit=self.shutdown)
     sio = stdio.StandardIO(console)
     log.msg('Dialing: %s' % (cmd_options['code'],))
     yield console.dial(cmd_options['code'])
     returnValue(sio)
Ejemplo n.º 3
0
 def ussd_session(self, modem, options):
     log.msg('Connecting to modem.')
     cmd_options = options.subOptions
     yield modem.configure_modem()
     log.msg('Connected, starting console for: %s' %
             (cmd_options['code'], ))
     console = USSDConsole(modem, on_exit=self.shutdown)
     sio = stdio.StandardIO(console)
     log.msg('Dialing: %s' % (cmd_options['code'], ))
     yield console.dial(cmd_options['code'])
     returnValue(sio)
Ejemplo n.º 4
0
class USSDConsoleTestCase(TxGSMBaseTestCase):
    def setUp(self):
        super(USSDConsoleTestCase, self).setUp()
        self.exit = Mock()
        self.console = USSDConsole(self.modem, on_exit=self.exit)
        self.console_transport = proto_helpers.StringTransport()
        self.console.makeConnection(self.console_transport)

    def test_dial_single_screen_session(self):
        d = self.console.dial('*100#')
        self.assertExchange(input=['AT+CUSD=1,"*100#",15'],
                            output=['OK', '+CUSD: 2,"foo",25'])
        self.assertEqual(self.console_transport.value(), 'foo\n')
        return d

    def test_dial_multiple_screen_session(self):
        d = self.console.dial('*100#')
        self.assertExchange(input=['AT+CUSD=1,"*100#",15'],
                            output=['OK', '+CUSD: 1,"what is your name?",25'])
        self.assertEqual(self.console_transport.value(),
                         'what is your name?\n%s> ' % (self.console.prefix, ))
        self.console_transport.clear()
        self.console.lineReceived('foo')
        self.assertExchange(input=['AT+CUSD=1,"foo",15'],
                            output=['OK', '+CUSD: 2,"thanks!",25'])
        self.assertEqual(self.console_transport.value(), 'thanks!\n')
        self.assertTrue(self.exit.called)
        return d
Ejemplo n.º 5
0
class USSDConsoleTestCase(TxGSMBaseTestCase):

    def setUp(self):
        super(USSDConsoleTestCase, self).setUp()
        self.exit = Mock()
        self.console = USSDConsole(self.modem, on_exit=self.exit)
        self.console_transport = proto_helpers.StringTransport()
        self.console.makeConnection(self.console_transport)

    def test_dial_single_screen_session(self):
        d = self.console.dial('*100#')
        self.assertExchange(
            input=['AT+CUSD=1,"*100#",15'],
            output=[
                'OK',
                '+CUSD: 2,"foo",25'
            ])
        self.assertEqual(self.console_transport.value(), 'foo\n')
        return d

    def test_dial_multiple_screen_session(self):
        d = self.console.dial('*100#')
        self.assertExchange(
            input=['AT+CUSD=1,"*100#",15'],
            output=[
                'OK',
                '+CUSD: 1,"what is your name?",25'
            ])
        self.assertEqual(self.console_transport.value(),
                         'what is your name?\n%s> ' % (self.console.prefix,))
        self.console_transport.clear()
        self.console.lineReceived('foo')
        self.assertExchange(
            input=['AT+CUSD=1,"foo",15'],
            output=[
                'OK',
                '+CUSD: 2,"thanks!",25'
            ])
        self.assertEqual(self.console_transport.value(), 'thanks!\n')
        self.assertTrue(self.exit.called)
        return d
Ejemplo n.º 6
0
 def setUp(self):
     super(USSDConsoleTestCase, self).setUp()
     self.exit = Mock()
     self.console = USSDConsole(self.modem, on_exit=self.exit)
     self.console_transport = proto_helpers.StringTransport()
     self.console.makeConnection(self.console_transport)
Ejemplo n.º 7
0
 def setUp(self):
     super(USSDConsoleTestCase, self).setUp()
     self.exit = Mock()
     self.console = USSDConsole(self.modem, on_exit=self.exit)
     self.console_transport = proto_helpers.StringTransport()
     self.console.makeConnection(self.console_transport)