def test_incoming(self):
     self.check_incoming_call()
     self.results = []
     self._called = False
     worker = gammu.worker.GammuWorker(self.callback)
     worker.configure(self.get_statemachine().GetConfig())
     worker.initiate()
     worker.enqueue('SetIncomingCallback', (self.call_callback, ))
     worker.enqueue('SetIncomingCall')
     self.fake_incoming_call()
     worker.terminate()
     self.assertTrue(self._called)
Esempio n. 2
0
    def test_worker(self):
        worker = gammu.worker.GammuWorker(self.callback)
        worker.configure(self.get_statemachine().GetConfig())
        # We can directly invoke commands
        worker.enqueue('GetManufacturer')
        worker.enqueue('GetSIMIMSI')
        worker.enqueue('GetIMEI')
        worker.enqueue('GetOriginalIMEI')
        worker.enqueue('GetManufactureMonth')
        worker.enqueue('GetProductCode')
        worker.enqueue('GetHardware')
        worker.enqueue('GetDateTime')
        # We can create compound tasks
        worker.enqueue('CustomGetInfo', commands=[
            'GetModel',
            'GetBatteryCharge'
        ])
        # We can pass parameters
        worker.enqueue('GetMemory', ('SM', 1))
        # We can create compound tasks with parameters:
        worker.enqueue('CustomGetAllMemory', commands=[
            ('GetMemory', ('SM', 1)),
            ('GetMemory', ('SM', 2)),
            ('GetMemory', ('SM', 3)),
            ('GetMemory', ('SM', 4)),
            ('GetMemory', ('SM', 5))
        ])
        worker.initiate()
        # We can also pass commands with named parameters
        worker.enqueue('GetSMSC', {'Location': 1})
        worker.terminate()

        # Remove GetDateTime from comparing as the value changes
        for i in range(len(self.results)):
            if self.results[i][0] == 'GetDateTime':
                self.assertEqual(self.results[i][2], 'ERR_NONE')
                self.assertEqual(self.results[i][3], 100)
                del self.results[i]
                break

        self.maxDiff = None
        self.assertEqual(WORKER_EXPECT, self.results)
Esempio n. 3
0
    def test_worker(self):
        worker = gammu.worker.GammuWorker(self.callback)
        worker.configure(self.get_statemachine().GetConfig())
        # We can directly invoke commands
        worker.enqueue('GetManufacturer')
        worker.enqueue('GetSIMIMSI')
        worker.enqueue('GetIMEI')
        worker.enqueue('GetOriginalIMEI')
        worker.enqueue('GetManufactureMonth')
        worker.enqueue('GetProductCode')
        worker.enqueue('GetHardware')
        worker.enqueue('GetDateTime')
        # We can create compound tasks
        worker.enqueue('CustomGetInfo',
                       commands=['GetModel', 'GetBatteryCharge'])
        # We can pass parameters
        worker.enqueue('GetMemory', ('SM', 1))
        # We can create compound tasks with parameters:
        worker.enqueue('CustomGetAllMemory',
                       commands=[('GetMemory', ('SM', 1)),
                                 ('GetMemory', ('SM', 2)),
                                 ('GetMemory', ('SM', 3)),
                                 ('GetMemory', ('SM', 4)),
                                 ('GetMemory', ('SM', 5))])
        worker.initiate()
        # We can also pass commands with named parameters
        worker.enqueue('GetSMSC', {'Location': 1})
        worker.terminate()

        # Remove GetDateTime from comparing as the value changes
        for i in range(len(self.results)):
            if self.results[i][0] == 'GetDateTime':
                self.assertEqual(self.results[i][2], 'ERR_NONE')
                self.assertEqual(self.results[i][3], 100)
                del self.results[i]
                break

        self.maxDiff = None
        self.assertEqual(WORKER_EXPECT, self.results)
Esempio n. 4
0
def main():
    '''
    Main code to talk with worker.
    '''
    worker = gammu.worker.GammuWorker(callback)
    worker.configure(read_config())
    # We can directly invoke commands
    worker.enqueue('GetManufacturer')
    worker.enqueue('GetSIMIMSI')
    worker.enqueue('GetIMEI')
    worker.enqueue('GetOriginalIMEI')
    worker.enqueue('GetManufactureMonth')
    worker.enqueue('GetProductCode')
    worker.enqueue('GetHardware')
    worker.enqueue('GetDateTime')
    # We can create compound tasks
    worker.enqueue('CustomGetInfo', commands=['GetModel', 'GetBatteryCharge'])
    # We can pass parameters
    worker.enqueue('GetMemory', ('SM', 1))
    # We can create compound tasks with parameters:
    worker.enqueue('CustomGetAllMemory',
                   commands=[
                       ('GetMemory', ('SM', 1)), ('GetMemory', ('SM', 2)),
                       ('GetMemory', ('SM', 3)), ('GetMemory', ('SM', 4)),
                       ('GetMemory', ('SM', 5))
                   ])
    print('All commands submitted')
    worker.initiate()
    print('Worker started')
    # We can also pass commands with named parameters
    worker.enqueue('GetSMSC', {'Location': 1})
    print('Submitted additional command')
    worker.terminate()
    print('Worker done')
Esempio n. 5
0
def main():
    '''
    Main code to talk with worker.
    '''
    worker = gammu.worker.GammuWorker(callback)
    worker.configure(read_config())
    # We can directly invoke commands
    worker.enqueue('GetManufacturer')
    worker.enqueue('GetSIMIMSI')
    worker.enqueue('GetIMEI')
    worker.enqueue('GetOriginalIMEI')
    worker.enqueue('GetManufactureMonth')
    worker.enqueue('GetProductCode')
    worker.enqueue('GetHardware')
    worker.enqueue('GetDateTime')
    # We can create compound tasks
    worker.enqueue('CustomGetInfo', commands=[
        'GetModel',
        'GetBatteryCharge'
        ])
    # We can pass parameters
    worker.enqueue('GetMemory', ('SM', 1))
    # We can create compound tasks with parameters:
    worker.enqueue('CustomGetAllMemory', commands=[
        ('GetMemory', ('SM', 1)),
        ('GetMemory', ('SM', 2)),
        ('GetMemory', ('SM', 3)),
        ('GetMemory', ('SM', 4)),
        ('GetMemory', ('SM', 5))
        ])
    print('All commands submitted')
    worker.initiate()
    print('Worker started')
    # We can also pass commands with named parameters
    worker.enqueue('GetSMSC', {'Location': 1})
    print('Submitted additional command')
    worker.terminate()
    print('Worker done')