1
0
Fork 0

sms: Fix the test for sending SMS (still not verifying the result)

Handle failures to cancel a SMS gracefully (as the SMS could have
been submitted from query to delete), handle registeration failures
properly by ignoring them (the modem has a valid SIM card and eventually
should be able to register).
This commit is contained in:
Holger Hans Peter Freyther 2012-11-10 19:02:54 +01:00
parent 27bfbde0b5
commit f338470da9
2 changed files with 15 additions and 5 deletions

View File

@ -36,16 +36,19 @@ class NitbTest(object):
imsi = mod.sim().imsi()
if not self.socket.imsi_present(imsi):
print("Modem('%s') doesn't have a provisioned SIM" % mod.name)
print("Modem('%s') doesn't have a provisioned SIM('%s')" % (mod.name, imsi))
continue
self.avail_modems.add(mod)
self.avail_modems.append(mod)
ext = self.socket.extension(imsi)
self.ext2mod[ext] = mod
self.mod2ext[mod] = ext
# Now register
mod.register()
try:
mod.register()
except:
print("Registering %s failed. Continuing anyway" % mod)
# TODO: Check if all modems are registered? But this would delay the
# test further. But the modem's SIM card is inside the NITB HLR so it

11
ofono-end-to-end/sms_sending_test.py Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env python
# Copyright (C) 2012 Holger Hans Peter Freyther
#
# This program is free software: you can redistribute it and/or modify
@ -36,14 +37,20 @@ class SmsMassTest(NitbTest):
# Now wait.... TODO. We could connect to the MessageAdded/Removed
# signal and enter the event loop here...
print("Queued a lot of SMS... now waiting")
if len(self.avail_modems) > 0:
print("Queued a lot of SMS... now waiting.")
else:
print("No SMS queued due lack of modems.")
def clear_all_sms(self):
# Clear all SMS so we can easily verify we get SMS..
for modem in self.avail_modems:
sms = modem.sms()
for msg in sms.all_message_names():
sms.get_message(sms).cancel()
try:
sms.get_message(msg).cancel()
except:
print("Deleting SMS('%s') failed. Continuing." % msg)
def send_sms(self, nr, modem, extension_lists):
# Send a SMS to all extensions