summaryrefslogtreecommitdiffstats
path: root/test/create-context
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2009-10-25 00:57:32 +0900
committerMarcel Holtmann <marcel@holtmann.org>2009-10-25 00:57:32 +0900
commitecc542195757083478035414cb6aa47cfef2aa1d (patch)
tree1731cb8d3efb65515116bba61eb5cdefa8ba83e0 /test/create-context
parent6cefd2e69330be619dd8c7a1ece1582e8db7c429 (diff)
downloadofono-ecc542195757083478035414cb6aa47cfef2aa1d.tar.bz2
Add simple test script for creating a context and setting APN
Diffstat (limited to 'test/create-context')
-rwxr-xr-xtest/create-context37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/create-context b/test/create-context
new file mode 100755
index 00000000..138efd15
--- /dev/null
+++ b/test/create-context
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+
+import sys
+import dbus
+
+bus = dbus.SystemBus()
+
+manager = dbus.Interface(bus.get_object('org.ofono', '/'),
+ 'org.ofono.Manager')
+
+properties = manager.GetProperties()
+
+for path in properties["Modems"]:
+ modem = dbus.Interface(bus.get_object('org.ofono', path),
+ 'org.ofono.Modem')
+
+ properties = modem.GetProperties()
+
+ if "org.ofono.DataConnectionManager" not in properties["Interfaces"]:
+ continue
+
+ connmgr = dbus.Interface(bus.get_object('org.ofono', path),
+ 'org.ofono.DataConnectionManager')
+
+ properties = connmgr.GetProperties()
+
+ if (properties["PrimaryContexts"] == []):
+ path = connmgr.CreateContext()
+ else:
+ path = properties["PrimaryContexts"][0]
+
+ context = dbus.Interface(bus.get_object('org.ofono', path),
+ 'org.ofono.PrimaryDataContext')
+
+ context.SetProperty("AccessPointName", sys.argv[1])
+
+ print "Setting APN of %s to %s" % (path, sys.argv[1])