[pkg-fso-commits] [SCM] FSO frameworkd Debian packaging branch, master, updated. milestone4-368-g700ab82
Daniel Willmann
daniel at totalueberwachung.de
Mon Feb 2 18:51:51 UTC 2009
The following commit has been merged in the master branch:
commit 08ea27073163c1c3ac6148c59a30121012a8c45b
Author: Daniel Willmann <daniel at totalueberwachung.de>
Date: Tue Jan 6 17:19:14 2009 +0100
ogsmd: Move SMS tests into its own unittest under tests/
diff --git a/framework/subsystems/ogsmd/gsm/sms.py b/framework/subsystems/ogsmd/gsm/sms.py
index 59c7f21..2187448 100644
--- a/framework/subsystems/ogsmd/gsm/sms.py
+++ b/framework/subsystems/ogsmd/gsm/sms.py
@@ -606,93 +606,4 @@ Alphabet: %s
Language: %s
Message: %s""" % (self.sn, self.mid, self.page, self.dcs_alphabet, self.dcs_language, repr(self.ud))
-if __name__ == "__main__":
- import sys
- #============================================================================#
- def readFromFile( path ):
- #============================================================================#
- try:
- value = open( path, 'r' ).read().strip()
- except IOError, e:
- print( "(could not read from '%s': %s)" % ( path, e ) )
- return "N/A"
- else:
- return value
-
- pdus_MT = [
- "0791448720900253040C914497035290960000500151614414400DD4F29C9E769F41E17338ED06",
- "0791448720003023440C91449703529096000050015132532240A00500037A020190E9339A9D3EA3E920FA1B1466B341E472193E079DD3EE73D85DA7EB41E7B41C1407C1CBF43228CC26E3416137390F3AABCFEAB3FAAC3EABCFEAB3FAAC3EABCFEAB3FAAC3EABCFEAB3FADC3EB7CFED73FBDC3EBF5D4416D9457411596457137D87B7E16438194E86BBCF6D16D9055D429548A28BE822BA882E6370196C2A8950E291E822BA88",
- "0791448720003023440C91449703529096000050015132537240310500037A02025C4417D1D52422894EE5B17824BA8EC423F1483C129BC725315464118FCDE011247C4A8B44",
- "07914477790706520414D06176198F0EE361F2321900005001610013334014C324350B9287D12079180D92A3416134480E",
- "0791448720003023440C91449703529096000050016121855140A005000301060190F5F31C447F83C8E5327CEE0221EBE73988FE0691CB65F8DC05028190F5F31C447F83C8E5327CEE028140C8FA790EA2BF41E472193E7781402064FD3C07D1DF2072B90C9FBB402010B27E9E83E86F10B95C86CF5D2064FD3C07D1DF2072B90C9FBB40C8FA790EA2BF41E472193E7781402064FD3C07D1DF2072B90C9FBB402010B27E9E83E8",
- "0791448720003023440C91449703529096000050016121850240A0050003010602DE2072B90C9FBB402010B27E9E83E86F10B95C86CF5D201008593FCF41F437885C2EC3E72E100884AC9FE720FA1B442E97E1731708593FCF41F437885C2EC3E72E100884AC9FE720FA1B442E97E17317080442D6CF7310FD0D2297CBF0B90B040221EBE73988FE0691CB65F8DC05028190F5F31C447F83C8E5327CEE028140C8FA790EA2BF41",
- "0791448720003023440C91449703529096000050016121854240A0050003010603C8E5327CEE0221EBE73988FE0691CB65F8DC05028190F5F31C447F83C8E5327CEE028140C8FA790EA2BF41E472193E7781402064FD3C07D1DF2072B90C9FBB402010B27E9E83E86F10B95C86CF5D201008593FCF41F437885C2EC3E72E10B27E9E83E86F10B95C86CF5D201008593FCF41F437885C2EC3E72E100884AC9FE720FA1B442E97E1",
- "0791448720003023400C91449703529096000050016121858240A0050003010604E62E100884AC9FE720FA1B442E97E17317080442D6CF7310FD0D2297CBF0B90B040221EBE73988FE0691CB65F8DC0542D6CF7310FD0D2297CBF0B90B040221EBE73988FE0691CB65F8DC05028190F5F31C447F83C8E5327CEE028140C8FA790EA2BF41E472193E7781402064FD3C07D1DF2072B90C9FBB402010B27E9E83E86F10B95C86CF5D",
- "0791448720003023400C91449703529096000050016121853340A005000301060540C8FA790EA2BF41E472193E7781402064FD3C07D1DF2072B90C9FBB402010B27E9E83E86F10B95C86CF5D201008593FCF41F437885C2EC3E72E100884AC9FE720FA1B442E97E17317080442D6CF7310FD0D2297CBF0B90B84AC9FE720FA1B442E97E17317080442D6CF7310FD0D2297CBF0B90B040221EBE73988FE0691CB65F8DC05028190",
- "0791448720003023440C914497035290960000500161218563402A050003010606EAE73988FE0691CB65F8DC05028190F5F31C447F83C8E5327CEE0281402010",
- "07918167830071F1040BD0C7F7FBCC2E030000808010800120804AD0473BED2697D9F3B20E644CCBDBE136835C6681CCF2B20B147381C2F5B30B04C3E96630500B1483E96030501A34CDB7C5E9B71B847AB2CB2062987D0E87E5E414",
- "07918167830071F1040BD0C7F7FBCC2E0300008080203200748078D0473BED2697D9F3B20E442DCFE9A076793E0F9FCBA07B9A8E0691C3EEF41C0D1AA3C3F2F0985E96CF75A00EE301E22C1C2C109B217781642E50B87E76816433DD0C066A81E60CB70B347381C2F5B30B",
- "0791447758100650040C9194714373238200008080312160304019D4F29C0E6A97E7F3F0B90CB2A7C3A0791A7E0ED3CB2E",
- "0791447758100650040DD0F334FC1CA6970100008080312170224008D4F29CDE0EA7D9",
- "0791889653704434040C9188969366423600008090017134632302CA34",
- "0791889663000009040C918896631009910008809061510540238453485B89FF0167094EF681C97D055FC38DF376844E8B548C4F608AAA54E6FF016709500B59735B69525B52A0516590FD6703753759738AAA60F389818A8D8B584F60FF0C624B6A5F5FEB64A500350032003163090033628A63E16A5F67038A8D8B5859793002621664A50035003200316309003251FA73FE611B60C5597D904B5146FF01",
- "0791889663000019040C918896631030990008809071619483234E60A86709672A63A54F8696FB003A000A00300039002F00310037002000300034003A003400330050004D4F8681EA0030003900380038003500360033003900390036002000280032901A0029000A",
- "0791889663000009040C918896631009910008809071717374238A7E415FD951B76DE1768457CE5E02FF0C4F609858610F548C6211505A670B53CB55CEFF1F624B6A5F76F464A500350032003163090031518D630900338F3851650033003200320030003000390033621167037B495F854F60771F5FC376844F8696FB007E621664A5003500320031630900328AC75FC3804A59298DA330014EA453CB8D855BB96613007E",
- "0791889663000009040C91889671342752000080908171153223282073788E4EBFDD2B1CCE96C3E16AB6592E67D32944ECF7780D9A8FE5E5B25BA468B514",
- "0791889663000019040C918896138188020008809091907405238050B38A0A606F003F767E842C734E91D190017D664F6076846D3B52D590FD958B8DD15169500B67084E86FF0C4F605831540D4E8655CEFF0173FE572853EA898150B34E00500B7A7A767D7C218A0A52300030003900330031002D003100380031003900330030514D8CBB5831540DFF0C6A5F67035C31662F4F6076845594FF01",
- "07918896532430280406918816880000809042215024235FC3309B0D42BEDB6590380F22A7C3ECB4FB0CE2AD7C20DEF85D77D3E579D0F84D2E836839900FC403C1D16F7719E47E837CA01D681866B341ECF738CC06A9EB733A889C0EB341ECF738CC06C1D16F7719E47EBB00",
- "07914140279505F74404D011002000800190819234000704010200018000",
- "07914140279505F74404D011002000800190913285000704010200028000",
- "07914140279505F74404D011002000800190320243000704010200038000",
- "0791947106004034040C9194713900303341008011311265854059D6B75B076A86D36CF11BEF024DD365103A2C2EBB413390BB5C2F839CE1315A9E1EA3E96537C805D2D6DBA0A0585E3797DDA0FB1ECD2EBB41D37419244ED3E965906845CBC56EB9190C069BCD6622",
- "0791947106004034040C9194713900303341008011312270804059D6B75B076A86D36CF11BEF024DD365103A2C2EBB413490BB5C2F839CE1315A9E1EA3E96537C805D2D6DBA0A0585E3797DDA0FB1ECD2EBB41D37419244ED3E965906845CBC56EB9190C069BCD6622",
-
- ]
-
- pdus_MO = [
- "07910447946400F011000A9270042079330000AA0161",
- "079194710716000001310C919491103246570000061B1EBD3CA703",
- ]
-
- pdus_ACKPDU = [
- "010080110191146140",
- "010080112102618040",
- ]
-
- pdus_CB = [
- "001000DD001133DAED46ABD56AB5186CD668341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D100",
- ]
-
- if len(sys.argv) == 3:
- pdus_MT = readFromFile(sys.argv[1]).split("\n")
- pdus_MO = readFromFile(sys.argv[2]).split("\n")
-
-
- def testpdu(pdu, dir):
- try:
- sms = SMS.decode(pdu, dir)
- genpdu = sms.pdu()
- if pdu != genpdu:
- print "ERROR: Reencoded SMS doesn't match"
- print "Orig PDU: ", pdu
- print "ReencPDU: ", genpdu
- print repr(sms)
- sms = SMS.decode(genpdu, dir)
- print repr(sms)
- except SMSError, e:
- print "%s, PDU was: %s\n" % (e, pdu)
-
- for pdu in pdus_MT:
- testpdu(pdu, "sms-deliver")
-
- for pdu in pdus_MO:
- testpdu(pdu, "sms-submit")
-
- for pdu in pdus_ACKPDU:
- testpdu(pdu, "sms-submit-report")
-
- for pdu in pdus_CB:
- cb = CellBroadcast.decode(pdu)
- print repr(cb)
-
# vim: expandtab shiftwidth=4 tabstop=4
diff --git a/tests/ogsmd.py b/tests/ogsmd.py
deleted file mode 100755
index 95d869a..0000000
--- a/tests/ogsmd.py
+++ /dev/null
@@ -1,434 +0,0 @@
-#!/usr/bin/env python
-"""
-ogsmd tests
-
-(C) 2008 Guillaume 'Charlie' Chereau <charlie at openmoko.org>
-(C) 2008 Michael 'Mickey' Lauer <mlauer at vanille-media.de>
-(C) 2008 Openmoko, Inc.
-GPLv2 or later
-"""
-
-# Set those parameters to reflect the real conditions of the test
-# TODO: make these command line options
-
-import dbus
-from dbus.mainloop.glib import DBusGMainLoop
-DBusGMainLoop(set_as_default=True)
-import gobject
-import inspect
-import thread
-import time
-import sys
-from Queue import Queue
-import types
-
-verbose = True
-
-class TE( Exception ):
- pass
-
-queue = Queue()
-
-#=========================================================================#
-def signalHandler( *args, **kwargs ):
-#=========================================================================#
- """
- Signal handler that just puts the received signal with all its data into the queue
- """
- log( "\n" )
- log( "-"*78 )
- log( "%s.%s (%s)" % ( kwargs["interface"], kwargs["member"], args ) )
- log( "-"*78 )
- queue.put( ( kwargs["member"], args ) )
-
-#=========================================================================#
-def logged( fn ):
-#=========================================================================#
- """
- Decorator that logs the name of a function each time it is called.
- If the function is a bound method, it also prints the classname.
- """
- def logIt( *args, **kwargs ):
- calldepth = len( inspect.stack() )-1
- try:
- classname = args[0].__class__.__name__
- except AttributeError:
- classname = ""
- print "%s> %s.%s: ENTER %s,%s" % ( '|...' * calldepth, classname, fn.__name__, repr(args[1:]), repr(kwargs) )
- result = fn( *args, **kwargs )
- print "%s> %s.%s: LEAVE" % ( '|...' * calldepth, classname, fn.__name__ )
- return result
-
- logIt.__dict__ = fn.__dict__
- logIt.__name__ = fn.__name__
- logIt.__doc__ = fn.__doc__
- return logIt
-
-
-#=========================================================================#
-def log( *args ):
-#=========================================================================#
- """Only print if we are in verbose mode"""
- if verbose:
- for i in args:
- print prettyPrint( i ),
- if type( args[-1] ) == type( "" ) and args[-1].endswith( "..." ):
- pass
- else:
- print
- print
- sys.stdout.flush()
-
-
-def prettyPrint( expression ):
- if type( expression ) == dbus.types.Struct:
- result = ""
- for val in expression:
- result += "%s, " % prettyPrint(val)
- return "( %s )" % result[:-2]
- if type( expression ) == dbus.types.Array:
- result = ""
- for val in expression:
- result += "%s, " % prettyPrint(val)
- return "[ %s ]" % result[:-2]
- elif type( expression ) == dbus.types.Dictionary:
- result = ""
- for key, val in expression.items():
- result += "\n %s: %s" % ( prettyPrint(key), prettyPrint(val) )
- return "{ %s }" % result
- elif type( expression ) == dbus.types.String:
- return "'%s'" % expression
- else:
- try:
- return "%s" % expression
- except TypeError:
- return repr(expression)
-
-#=========================================================================#
-class TestRunner( object ):
-#=========================================================================#
-
- def __init__( self, failOnFirstFailed = True ):
- self.tests = []
- self.results = []
-
- def addTest( self, test, fatal = False ):
- test.fatal = fatal
- self.tests.append( test )
-
- def run( self ):
- # give mainloop a chance to set everything up
- time.sleep( 1 )
- for test in self.tests:
- kontinue = self.runTest( test )
- if not kontinue:
- print "TR: [FATAL FAIL]"
- break
- self.testEnds()
-
- def runTest( self, test ):
- print "="*78
- print "TR: [NEXT]", test.name, '\n'
- try:
- result = test.run()
- except Exception, e:
- print "ERROR during test:", e
- return self.testResult( test, False )
- else:
- return self.testResult( test, True )
-
- def testResult( self, test, result ):
- if result:
- print "TR: [PASS]", test.name
- self.results.append( ( test, "PASS" ) )
- return True
- else:
- print "TR: [FAIL]", test.name
- self.results.append( ( test, "FAIL" ) )
- return not test.fatal
-
- def testEnds( self ):
- # FIXME print summary
- print "TR: all tests done, quitting"
- mainloop.quit() # no more tests
-
-#=========================================================================#
-class AbstractTest( object ):
-#=========================================================================#
- """
- An abstract test class
- """
- def __init__( self, counter = 1, name = None ):
- self.name = name or self.__class__.__name__
-
- def failWithDbusError( self, func, error ):
- try:
- func()
- except dbus.DBusException, e:
- if e.get_dbus_name() == error:
- log( "fails with", e.get_dbus_name(), "(OK)" )
- else:
- log( "fails with", e.get_dbus_name(), "(UNEXPECTED)" )
- raise AssertionError( "unexpected dbus error" )
- else:
- assert False, "%s did not fail. Expected was %s" % ( func, error )
-
-#=========================================================================#
-class DeviceAndSimAuthTest( AbstractTest ):
-#=========================================================================#
- """
- org.freesmartphone.GSM.Device
- * GetInfo
- * GetFeatures
- * SetAntennaPower
- * NYI PrepareForSuspend()
- * NYI RecoverFromResume()
-
- org.freesmartphone.GSM.SIM
- * GetAuthStatus
- * SendAuthCode
- * GetSimInfo
-
- """
- serial = 0
-
- def run( self ):
- log( "get device info..." )
- info = device.GetInfo()
- log( "ok. info:", info )
-
- log( "get device features..." )
- features = device.GetFeatures()
- log( "ok. device features:", features )
-
- log( "antenna power off..." )
- device.SetAntennaPower( False )
- log( "ok" )
-
- log( "antenna power on..." )
- if options.SIM_LOCKED:
- self.failWithDbusError( lambda: device.SetAntennaPower( True ), "org.freesmartphone.GSM.SIM.AuthFailed" )
-
- log( "checking auth status..." )
- auth = sim.GetAuthStatus()
-
- if options.SIM_LOCKED:
- assert auth == "SIM PIN"
- else:
- assert auth == "READY"
- log( "ok. auth status is:", auth )
-
- if options.SIM_LOCKED:
- log( "sending unlock code..." )
- sim.SendAuthCode( options.SIM_PIN )
- log( "ok. auth status now:", sim.GetAuthStatus() )
-
- # FIXME we should have got an AuthChange signal in the meantime
- assert sim.GetAuthStatus() == "READY"
-
- log( "get sim info..." )
- info = sim.GetSimInfo()
- log( "ok. info:", info )
-
- # TODO should we check Unlock and ChangeAuthCode or is that too dangerous?
-
-#=========================================================================#
-class AuxilliarySimTest( AbstractTest ):
-#=========================================================================#
- """
- org.freesmartphone.GSM.SIM
-
- * GetEnableAuthCodeCheck()
- * SetEnableAuthCodeCheck()
- * GetHomeZones()
- * GetServiceCenterNumber()
- * SetServiceCenterNumber()
- """
- serial = 12
-
- def run( self ):
- pass
-
-#=========================================================================#
-class SimPhonebookTest( AbstractTest ):
-#=========================================================================#
- """
- org.freesmartphone.GSM.SIM
- """
- serial = 12
-
- def run( self ):
- pass
-
-#=========================================================================#
-class SimMessagebookTest( AbstractTest ):
-#=========================================================================#
- """
- org.freesmartphone.GSM.SIM
- """
- serial = 12
-
- def run( self ):
- pass
-
-#=========================================================================#
-class NetworkAutoRegisterTest( AbstractTest ):
-#=========================================================================#
- """
- org.freesmartphone.GSM.Network
-
- * Unregister()
- * GetStatus()
- * Register()
- * GetSignalStrength()
- """
- serial = 10
-
- def run( self ):
- log( "unregistering..." )
- network.Unregister()
- log( "ok. checking status..." )
- status = network.GetStatus()
- assert status["registration"] == "unregistered"
- log( "ok. status now:", status )
-
- log( "checking signal strength..." )
- log( "ok:", network.GetSignalStrength() )
-
- log( "autoregistering..." )
- network.Register()
- assert status["registration"] == "home"
- log( "ok. checking status..." )
- status = network.GetStatus()
- log( "ok. status now:", status )
-
- log( "checking signal strength..." )
- log( "ok:", network.GetSignalStrength() )
-
-#=========================================================================#
-class NetworkSpecificRegisterTest( AbstractTest ):
-#=========================================================================#
- """
- org.freesmartphone.GSM.Network
-
- * ListProviders()
- * RegisterWithProvider()
- """
- serial = 20
-
- def run( self ):
- log( "checking available providers [will take some time]..." )
- providers = network.ListProviders( timeout = 1000 )
- log( "ok. provider list is:", providers )
-
- for code, status, name, nickname in providers:
- if status in ( "current", "available" ):
- log( "trying to specifically register w/", name, "..." )
- network.RegisterWithProvider( code )
- status = network.GetStatus()
- assert status["provider"] == str(code)
- log( "ok. status now:", status )
- break
- else:
- assert False, "can't find available providers. unable to continue"
-
-#=========================================================================#
-class CallCancelTest( AbstractTest ):
-#=========================================================================#
- """
- org.freesmartphone.GSM.Call
-
- * ReleaseAll()
- * ListCalls()
- * Initiate()
- * Release()
-
- """
- serial = 30
-
- def run( self ):
- log( "releasing all active call..." )
- call.ReleaseAll()
- log( "ok. calling", options.PHONE_NUMBER, "..." )
- index = call.Initiate( options.PHONE_NUMBER, "voice" )
- time.sleep( 1 )
- log( "ok. index =", index, ", checking calls..." )
- calls = call.ListCalls()
- log( "ok. calls:", calls )
- log( "waiting ten seconds to give call a chance to ring..." )
- time.sleep( 10 )
- call.Release( index )
- calls = call.ListCalls()
- log( "ok. calls now:", calls )
-
-#=========================================================================#
-if __name__ == "__main__":
-#=========================================================================#
- alltests = [ v for k, v in locals().items() if type(v) == types.TypeType and k.endswith( "Test" ) and k != "AbstractTest" ]
- alltests.sort( key=lambda element: element.serial )
- alltestnames = [ k for k, v in locals().items() if type(v) == types.TypeType and k.endswith( "Test" ) and k != "AbstractTest" ]
-
- from optparse import OptionParser
- usage = "ogsmd [options]"
- parser = OptionParser( usage )
- parser.add_option( "-a", "--all", dest="runAllTests", action="store_true",
- help="run all tests (%s)" % alltestnames )
- parser.add_option( "-t", "--test", dest="tests", metavar="TEST", action="append", type="choice", choices=alltestnames,
- help="run test TEST" )
- parser.add_option( "-p", "--pin", dest="SIM_PIN", metavar="PIN", action="store",
- help="SIM PIN to use" )
- parser.add_option( "-s", "--nosim", dest="SIM_PRESENT", action="store_false", default=True,
- help="assume there is no SIM present" )
- parser.add_option( "-l", "--nosimlock", dest="SIM_LOCKED", action="store_false", default=True,
- help="assume the SIM is not locked" )
- parser.add_option( "-n", "--number", dest="PHONE_NUMBER", metavar="NUMBER", action="store",
- help="set NUMBER for call and SMS tests" )
-
- options, args = parser.parse_args()
-
- if not options.runAllTests and not options.tests:
- parser.error( "need to supply at least one test or -a" )
- if options.SIM_PRESENT and options.SIM_LOCKED and not options.SIM_PIN:
- parser.error( "need a SIM PIN, if present and locked" )
- if options.SIM_PRESENT and not options.PHONE_NUMBER:
- parser.error( "need a phone number for call and message tests" )
-
- if options.runAllTests:
- tests = alltests
- else:
- tests = []
- for t in options.tests:
- tests.append( eval( t ) )
-
- runner = TestRunner()
- for test in tests:
- runner.addTest( test() )
-
- bus = dbus.SystemBus()
- try:
- device = sim = network = call = pdp = cb = bus.get_object( "org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device" )
- except dbus.DBusException:
- print "ogsmd not present. could not launch tests."
- sys.exit( -1 )
-
- bus.add_signal_receiver(
- signalHandler,
- None,
- None,
- "org.freesmartphone.ogsmd",
- "/org/freesmartphone/GSM/Device",
- sender_keyword = "sender",
- destination_keyword = "destination",
- interface_keyword = "interface",
- member_keyword = "member",
- path_keyword = "path" )
-
- gobject.threads_init()
-
- thread.start_new_thread( runner.run, () )
-
- mainloop = gobject.MainLoop()
- try:
- mainloop.run()
- except KeyboardInterrupt:
- mainloop.quit()
diff --git a/tests/sms.py b/tests/sms.py
new file mode 100755
index 0000000..63f3223
--- /dev/null
+++ b/tests/sms.py
@@ -0,0 +1,165 @@
+#!/usr/bin/env python
+"""
+SMS Testsuite
+
+(C) 2009 Daniel Willmann <daniel at totalueberwachung.de>
+GPLv2 or later
+"""
+
+
+import unittest
+import gobject
+import threading
+import dbus
+from dbus.mainloop.glib import DBusGMainLoop
+DBusGMainLoop(set_as_default=True)
+
+# Add ogsmd stuff to PYTHONPATH
+import sys
+sys.path.extend(["../", "../framework/subsystems/"])
+
+import test
+import framework.patterns.tasklet as tasklet
+from framework.subsystems.ogsmd.gsm.sms import *
+
+class SMSTests(unittest.TestCase):
+ """Some test cases for the sms subsystem"""
+ def setUp(self):
+ self.pdus_MT = [
+ "0791448720900253040C914497035290960000500151614414400DD4F29C9E769F41E17338ED06",
+ "0791448720003023440C91449703529096000050015132532240A00500037A020190E9339A9D3EA3E920FA1B1466B341E472193E079DD3EE73D85DA7EB41E7B41C1407C1CBF43228CC26E3416137390F3AABCFEAB3FAAC3EABCFEAB3FAAC3EABCFEAB3FAAC3EABCFEAB3FADC3EB7CFED73FBDC3EBF5D4416D9457411596457137D87B7E16438194E86BBCF6D16D9055D429548A28BE822BA882E6370196C2A8950E291E822BA88",
+ "0791448720003023440C91449703529096000050015132537240310500037A02025C4417D1D52422894EE5B17824BA8EC423F1483C129BC725315464118FCDE011247C4A8B44",
+ "07914477790706520414D06176198F0EE361F2321900005001610013334014C324350B9287D12079180D92A3416134480E",
+ "0791448720003023440C91449703529096000050016121855140A005000301060190F5F31C447F83C8E5327CEE0221EBE73988FE0691CB65F8DC05028190F5F31C447F83C8E5327CEE028140C8FA790EA2BF41E472193E7781402064FD3C07D1DF2072B90C9FBB402010B27E9E83E86F10B95C86CF5D2064FD3C07D1DF2072B90C9FBB40C8FA790EA2BF41E472193E7781402064FD3C07D1DF2072B90C9FBB402010B27E9E83E8",
+ "0791448720003023440C91449703529096000050016121850240A0050003010602DE2072B90C9FBB402010B27E9E83E86F10B95C86CF5D201008593FCF41F437885C2EC3E72E100884AC9FE720FA1B442E97E1731708593FCF41F437885C2EC3E72E100884AC9FE720FA1B442E97E17317080442D6CF7310FD0D2297CBF0B90B040221EBE73988FE0691CB65F8DC05028190F5F31C447F83C8E5327CEE028140C8FA790EA2BF41",
+ "0791448720003023440C91449703529096000050016121854240A0050003010603C8E5327CEE0221EBE73988FE0691CB65F8DC05028190F5F31C447F83C8E5327CEE028140C8FA790EA2BF41E472193E7781402064FD3C07D1DF2072B90C9FBB402010B27E9E83E86F10B95C86CF5D201008593FCF41F437885C2EC3E72E10B27E9E83E86F10B95C86CF5D201008593FCF41F437885C2EC3E72E100884AC9FE720FA1B442E97E1",
+ "0791448720003023400C91449703529096000050016121858240A0050003010604E62E100884AC9FE720FA1B442E97E17317080442D6CF7310FD0D2297CBF0B90B040221EBE73988FE0691CB65F8DC0542D6CF7310FD0D2297CBF0B90B040221EBE73988FE0691CB65F8DC05028190F5F31C447F83C8E5327CEE028140C8FA790EA2BF41E472193E7781402064FD3C07D1DF2072B90C9FBB402010B27E9E83E86F10B95C86CF5D",
+ "0791448720003023400C91449703529096000050016121853340A005000301060540C8FA790EA2BF41E472193E7781402064FD3C07D1DF2072B90C9FBB402010B27E9E83E86F10B95C86CF5D201008593FCF41F437885C2EC3E72E100884AC9FE720FA1B442E97E17317080442D6CF7310FD0D2297CBF0B90B84AC9FE720FA1B442E97E17317080442D6CF7310FD0D2297CBF0B90B040221EBE73988FE0691CB65F8DC05028190",
+ "0791448720003023440C914497035290960000500161218563402A050003010606EAE73988FE0691CB65F8DC05028190F5F31C447F83C8E5327CEE0281402010",
+ "07918167830071F1040BD0C7F7FBCC2E030000808010800120804AD0473BED2697D9F3B20E644CCBDBE136835C6681CCF2B20B147381C2F5B30B04C3E96630500B1483E96030501A34CDB7C5E9B71B847AB2CB2062987D0E87E5E414",
+ "07918167830071F1040BD0C7F7FBCC2E0300008080203200748078D0473BED2697D9F3B20E442DCFE9A076793E0F9FCBA07B9A8E0691C3EEF41C0D1AA3C3F2F0985E96CF75A00EE301E22C1C2C109B217781642E50B87E76816433DD0C066A81E60CB70B347381C2F5B30B",
+ "0791447758100650040C9194714373238200008080312160304019D4F29C0E6A97E7F3F0B90CB2A7C3A0791A7E0ED3CB2E",
+ "0791447758100650040DD0F334FC1CA6970100008080312170224008D4F29CDE0EA7D9",
+ "0791889653704434040C9188969366423600008090017134632302CA34",
+ "0791889663000009040C918896631009910008809061510540238453485B89FF0167094EF681C97D055FC38DF376844E8B548C4F608AAA54E6FF016709500B59735B69525B52A0516590FD6703753759738AAA60F389818A8D8B584F60FF0C624B6A5F5FEB64A500350032003163090033628A63E16A5F67038A8D8B5859793002621664A50035003200316309003251FA73FE611B60C5597D904B5146FF01",
+ "0791889663000019040C918896631030990008809071619483234E60A86709672A63A54F8696FB003A000A00300039002F00310037002000300034003A003400330050004D4F8681EA0030003900380038003500360033003900390036002000280032901A0029000A",
+ "0791889663000009040C918896631009910008809071717374238A7E415FD951B76DE1768457CE5E02FF0C4F609858610F548C6211505A670B53CB55CEFF1F624B6A5F76F464A500350032003163090031518D630900338F3851650033003200320030003000390033621167037B495F854F60771F5FC376844F8696FB007E621664A5003500320031630900328AC75FC3804A59298DA330014EA453CB8D855BB96613007E",
+ "0791889663000009040C91889671342752000080908171153223282073788E4EBFDD2B1CCE96C3E16AB6592E67D32944ECF7780D9A8FE5E5B25BA468B514",
+ "0791889663000019040C918896138188020008809091907405238050B38A0A606F003F767E842C734E91D190017D664F6076846D3B52D590FD958B8DD15169500B67084E86FF0C4F605831540D4E8655CEFF0173FE572853EA898150B34E00500B7A7A767D7C218A0A52300030003900330031002D003100380031003900330030514D8CBB5831540DFF0C6A5F67035C31662F4F6076845594FF01",
+ "07918896532430280406918816880000809042215024235FC3309B0D42BEDB6590380F22A7C3ECB4FB0CE2AD7C20DEF85D77D3E579D0F84D2E836839900FC403C1D16F7719E47E837CA01D681866B341ECF738CC06A9EB733A889C0EB341ECF738CC06C1D16F7719E47EBB00",
+ "07914140279505F74404D011002000800190819234000704010200018000",
+ "07914140279505F74404D011002000800190913285000704010200028000",
+ "07914140279505F74404D011002000800190320243000704010200038000",
+ "0791947106004034040C9194713900303341008011311265854059D6B75B076A86D36CF11BEF024DD365103A2C2EBB413390BB5C2F839CE1315A9E1EA3E96537C805D2D6DBA0A0585E3797DDA0FB1ECD2EBB41D37419244ED3E965906845CBC56EB9190C069BCD6622",
+ "0791947106004034040C9194713900303341008011312270804059D6B75B076A86D36CF11BEF024DD365103A2C2EBB413490BB5C2F839CE1315A9E1EA3E96537C805D2D6DBA0A0585E3797DDA0FB1ECD2EBB41D37419244ED3E965906845CBC56EB9190C069BCD6622",
+ ]
+
+ self.pdus_MO = [
+ "07910447946400F011000A9270042079330000AA0161",
+ "079194710716000001310C919491103246570000061B1EBD3CA703",
+ ]
+
+ self.pdus_ACKPDU = [
+ "010080110191146140",
+ "010080112102618040",
+ ]
+
+ self.pdus_CB = [
+ "001000DD001133DAED46ABD56AB5186CD668341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D168341A8D46A3D100",
+ ]
+ self.decodePDUs = []
+
+ def tearDown(self):
+ pass
+
+ def _recodepdu(self, pdu, dir):
+ sms = SMS.decode(pdu, dir)
+ genpdu = sms.pdu()
+ self.assert_(pdu == genpdu, "Reencoded SMS doesn't match, type %s" % dir)
+
+ def test_recode_sms(self):
+ """Try to decode SMS and reencode them to see if they match"""
+ for pdu in self.pdus_MT:
+ self._recodepdu(pdu, "sms-deliver")
+
+ for pdu in self.pdus_MO:
+ self._recodepdu(pdu, "sms-submit")
+
+ for pdu in self.pdus_ACKPDU:
+ self._recodepdu(pdu, "sms-submit-report")
+
+ def test_decode_sms(self):
+ """Try to decode some SMS"""
+
+ for pdu in self.pdus_MT:
+ SMS.decode(pdu, "sms-deliver")
+
+ for pdu in self.pdus_MO:
+ SMS.decode(pdu, "sms-submit")
+
+ for pdu in self.pdus_ACKPDU:
+ SMS.decode(pdu, "sms-submit-report")
+
+ def test_decode_cb(self):
+ """Try to decode CellBroadcast messages"""
+
+ for pdu in self.pdus_CB:
+ cb = CellBroadcast.decode(pdu)
+
+ def test_generate_sms(self):
+ """Create an SMS object and try to encode it"""
+ sms = SMS("sms-submit")
+ sms.oa = PDUAddress.guess("+491234")
+ self.assert_(sms.pdu() == "0001000691942143000000",
+ "SMS encoding incorrect, PDU is %s" %sms.pdu())
+ sms.ud = "Test"
+ self.assert_(sms.pdu() == "0001000691942143000004D4F29C0E",
+ "SMS encoding incorrect, PDU is %s" %sms.pdu())
+ sms.properties = { "pid": 10, "csm_id": 10, "csm_num": 2, "csm_seq" : 1}
+
+ self.assert_(sms.pdu() == "00410006919421430A000B0500030A0201A8E5391D",
+ "SMS encoding incorrect, PDU is %s" %sms.pdu())
+
+ # Extended plane
+ sms.ud = "{}[]\\"
+ self.assert_(sms.dcs_alphabet == "gsm_default",
+ "SMS extended alphabet encoding failed, alphabet used is: %s"
+ % sms.dcs_alphabet)
+ self.assert_(sms.pdu() == "00410006919421430A00110500030A020136A84D6AC3DBF8362F",
+ "SMS extended alphabet encoding failed, PDU:\n%s" % sms.pdu())
+
+ # UCS-2
+ sms.ud = u'Unicode\u2320'
+ self.assert_(sms.dcs_alphabet == "ucs2",
+ "SMS UCS2 alphabet encoding failed, alphabet used is: %s"
+ % sms.dcs_alphabet)
+ self.assert_(sms.pdu() == "00410006919421430A08160500030A02010055006E00690063006F006400652320",
+ "SMS UCS2 alphabet encoding failed, PDU:\n%s" % sms.pdu())
+
+
+if __name__ == '__main__':
+
+ suite = unittest.defaultTestLoader.loadTestsFromTestCase(SMSTests)
+ result = unittest.TextTestRunner(verbosity=3).run(suite)
+
+
+# #============================================================================#
+# def readFromFile( path ):
+# #============================================================================#
+# try:
+# value = open( path, 'r' ).read().strip()
+# except IOError, e:
+# print( "(could not read from '%s': %s)" % ( path, e ) )
+# return "N/A"
+# else:
+# return value
+#
+#
+# # Read PDUs from a file if passed as a parameter
+# if len(sys.argv) >= 2:
+# pdus_MT = readFromFile(sys.argv[1]).split("\n")
+# if len(sys.argv) == 3:
+# pdus_MO = readFromFile(sys.argv[2]).split("\n")
+
+
+# vim: expandtab shiftwidth=4 tabstop=4
--
FSO frameworkd Debian packaging
More information about the pkg-fso-commits
mailing list