summaryrefslogtreecommitdiffstats
path: root/src/osmo_gsm_tester/sms.py
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2017-05-30 15:13:29 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2017-05-31 16:14:08 +0200
commit996651a3a3e451d978a017f964bacccc0c19ed0f (patch)
tree3de663889c8836b23efe8cf4d052bd23c344256f /src/osmo_gsm_tester/sms.py
parentb8011695b8c771f157d83de3239cfd6ecf2e967f (diff)
Move Sms class to a separate module
Preparation for following commits to add smpp support, as we will have a class SmppClient with a method accepting an Sms object to send it. Change-Id: I1f28e14e963abb64df687b69d54975be2aeb0d0d
Diffstat (limited to 'src/osmo_gsm_tester/sms.py')
-rw-r--r--src/osmo_gsm_tester/sms.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/osmo_gsm_tester/sms.py b/src/osmo_gsm_tester/sms.py
new file mode 100644
index 0000000..64eca5a
--- /dev/null
+++ b/src/osmo_gsm_tester/sms.py
@@ -0,0 +1,48 @@
+# osmo_gsm_tester: DBUS client to talk to ofono
+#
+# Copyright (C) 2016-2017 by sysmocom - s.f.m.c. GmbH
+#
+# Author: Neels Hofmeyr <neels@hofmeyr.de>
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+class Sms:
+ _last_sms_idx = 0
+ msg = None
+
+ def __init__(self, from_msisdn=None, to_msisdn=None, *tokens):
+ Sms._last_sms_idx += 1
+ msgs = ['message nr. %d' % Sms._last_sms_idx]
+ msgs.extend(tokens)
+ if from_msisdn:
+ msgs.append('from %s' % from_msisdn)
+ if to_msisdn:
+ msgs.append('to %s' % to_msisdn)
+ self.msg = ', '.join(msgs)
+
+ def __str__(self):
+ return self.msg
+
+ def __repr__(self):
+ return repr(self.msg)
+
+ def __eq__(self, other):
+ if isinstance(other, Sms):
+ return self.msg == other.msg
+ return inself.msg == other
+
+ def matches(self, msg):
+ return self.msg == msg
+
+# vim: expandtab tabstop=4 shiftwidth=4