Update test scripts for the new provider interface
[platform/upstream/connman.git] / test / test-manager
1 #!/usr/bin/python
2
3 import dbus
4
5 bus = dbus.SystemBus()
6
7 manager = dbus.Interface(bus.get_object("org.moblin.connman", "/"),
8                                         "org.moblin.connman.Manager")
9
10 properties = manager.GetProperties()
11
12 def print_properties(key, value):
13         if key == "Profiles":
14                 interface = "org.moblin.connman.Profile"
15         elif key == "Devices":
16                 interface = "org.moblin.connman.Device"
17         elif key in ["Services", "Providers"]:
18                 interface = "org.moblin.connman.Service"
19         elif key == "Technologies":
20                 interface = "org.moblin.connman.Technology"
21         else:
22                 return
23
24         print "%s" % (key)
25         for path in value:
26                 print "    %s" % (path)
27                 obj = dbus.Interface(bus.get_object("org.moblin.connman", path),
28                                                                 interface)
29
30                 properties = obj.GetProperties()
31
32                 for key in properties.keys():
33                         if key in ["Devices", "Networks", "Services",
34                                                 "Providers", "Technologies"]:
35                                 continue
36
37                         if key in ["Powered", "Scanning", "Connected",
38                                         "Available", "Remember", "Default"]:
39                                 if properties[key] == dbus.Boolean(1):
40                                         val = "true"
41                                 else:
42                                         val = "false"
43                         elif key in ["Strength", "Priority"]:
44                                 val = int(properties[key])
45                         else:
46                                 val = str(properties[key])
47
48                         print "        %s = %s" % (key, val)
49
50                 if "Devices" in properties.keys():
51                         list = ""
52                         for path in properties["Devices"]:
53                                 val = str(path)
54                                 list = list + val[val.rfind("/") + 1:] + " "
55                         print "        Devices = [ %s]" % (list)
56                 if "Networks" in properties.keys():
57                         list = ""
58                         for path in properties["Networks"]:
59                                 val = str(path)
60                                 list = list + val[val.rfind("/") + 1:] + " "
61                         print "        Networks = [ %s]" % (list)
62                 if "Services" in properties.keys():
63                         list = ""
64                         for path in properties["Services"]:
65                                 val = str(path)
66                                 list = list + val[val.rfind("/") + 1:] + " "
67                         print "        Services = [ %s]" % (list)
68                 if "Providers" in properties.keys():
69                         list = ""
70                         for path in properties["Providers"]:
71                                 val = str(path)
72                                 list = list + val[val.rfind("/") + 1:] + " "
73                         print "        Providers = [ %s]" % (list)
74
75
76 for key in properties.keys():
77         if key in ["Profiles", "Devices", "Services", "Providers",
78                                                         "Technologies"]:
79                 print_properties(key, properties[key])
80         elif key in ["AvailableTechnologies", "EnabledTechnologies",
81                                         "ConnectedTechnologies",
82                                 "AvailableDebugs", "EnabledDebugs"]:
83                 print "%s" % (key)
84                 list = ""
85                 for val in properties[key]:
86                         list = list + val + " "
87                 print "    [ %s]" % (list)
88         elif key in ["OfflineMode", "Tethering"]:
89                 print "%s" % (key)
90                 if properties[key] == dbus.Boolean(1):
91                         print "    true"
92                 else:
93                         print "    false"
94         elif key in ["DefaultTechnology"]:
95                 print "%s" % (key)
96                 if properties[key] == "":
97                         print "    <none>"
98                 else:
99                         print "    %s" % (properties[key])
100         else:
101                 print "%s" % (key)
102                 print "    %s" % (properties[key])