Skip to content
Snippets Groups Projects
Commit 68ec9eb5 authored by Philip Withnall's avatar Philip Withnall
Browse files

bluez: Refactor test_dun and test_pan to share code


This introduces no behavioural changes.

Reviewed-by: default avatarSjoerd Simons <sjoerd.simons@collabora.co.uk>
Signed-off-by: default avatarPhilip Withnall <philip.withnall@collabora.co.uk>
Differential Revision: https://phabricator.apertis.org/D2310
parent c2158b81
No related branches found
No related tags found
No related merge requests found
......@@ -446,40 +446,41 @@ class PbapDeviceProfileTester(DeviceProfileTester):
signal_name="PropertiesChanged",
path_keyword='path')
def __test_dun_pan(self, path):
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("net.connman", "/"),
"net.connman.Manager")
services = manager.GetServices()
device_name = self._device_obj.Get(
'org.bluez.Device1',
'Name',
dbus_interface='org.freedesktop.DBus.Properties')
path = None
for s in services:
if s[1]["Name"] == device_name:
path = s[0]
break
if not path:
raise
service = dbus.Interface(bus.get_object("net.connman", path),
"net.connman.Service")
service.Connect(timeout=60000)
url = urllib.request.urlopen("http://connman.net")
f = open(path, 'w')
f.write(url.read(1000000))
f.close()
service.Disconnect(timeout=60000)
def test_dun(self):
TEST_START("DUN GW")
try:
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("net.connman", "/"),
"net.connman.Manager")
services = manager.GetServices()
device_name = self._device_obj.Get(
'org.bluez.Device1',
'Name',
dbus_interface='org.freedesktop.DBus.Properties')
path = None
for s in services:
if s[1]["Name"] == device_name:
path = s[0]
break
if not path:
raise
service = dbus.Interface(bus.get_object("net.connman", path),
"net.connman.Service")
service.Connect(timeout=60000)
url = urllib.request.urlopen("http://connman.net")
f = open(BASE_PATH + "/DUN", 'w')
f.write(url.read(1000000))
f.close()
service.Disconnect(timeout=60000)
self.__test_dun_pan(BASE_PATH + "/DUN")
TEST_PASSED("DUN GW")
except Exception as error:
TEST_FAILED("DUN GW: " + str(error))
......@@ -489,36 +490,7 @@ class PbapDeviceProfileTester(DeviceProfileTester):
TEST_START("PAN NAP")
try:
bus = dbus.SystemBus()
manager = dbus.Interface(bus.get_object("net.connman", "/"),
"net.connman.Manager")
services = manager.GetServices()
device_name = self._device_obj.Get(
'org.bluez.Device1',
'Name',
dbus_interface='org.freedesktop.DBus.Properties')
path = None
for s in services:
if s[1]["Name"] == device_name:
path = s[0]
break
if not path:
raise
service = dbus.Interface(bus.get_object("net.connman", path),
"net.connman.Service")
service.Connect(timeout=60000)
url = urllib2.urlopen("http://connman.net")
f = open(BASE_PATH + "/PAN", 'w')
f.write(url.read(1000000))
f.close()
service.Disconnect(timeout=60000)
self.__test_dun_pan(BASE_PATH + "/PAN")
TEST_PASSED("PAN NAP")
except Exception as error:
TEST_FAILED("PAN NAP: " + str(error))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment