|
@@ -19,8 +19,11 @@ except ImportError:
|
19
|
19
|
|
20
|
20
|
|
21
|
21
|
class test_smarthome(object):
|
22
|
|
- def __init__(self, rooms):
|
|
22
|
+ def __init__(self, rooms, mqtt_client):
|
|
23
|
+ self.mqtt_client = mqtt_client
|
23
|
24
|
self.__init__tcl__()
|
|
25
|
+ self.mqtt_client.add_callback('__info__', self.__test_system_info__)
|
|
26
|
+ self.mqtt_client.send('__info__', json.dumps(None))
|
24
|
27
|
# add testcases for switching devices
|
25
|
28
|
for name in rooms.getmembers():
|
26
|
29
|
obj = rooms.getobjbyname(name)
|
|
@@ -84,7 +87,12 @@ class test_smarthome(object):
|
84
|
87
|
self.tcl[jsonlog.MAIN_KEY_SYSTEM_INFO] = system_info
|
85
|
88
|
self.tcl["testcase_names"] = report.TCEL_NAMES
|
86
|
89
|
|
87
|
|
- def __eval_tcl__(self):
|
|
90
|
+ def __test_system_info__(self, client, userdata, message):
|
|
91
|
+ data = json.loads(message.payload)
|
|
92
|
+ if data is not None:
|
|
93
|
+ self.tcl[jsonlog.MAIN_KEY_TESTOBJECT_INFO] = data
|
|
94
|
+
|
|
95
|
+ def close(self):
|
88
|
96
|
path = os.path.abspath(os.path.join(os.path.basename(__file__), '..'))
|
89
|
97
|
|
90
|
98
|
with open(os.path.join(path, "testresults", "testrun.json"), "w") as fh:
|
|
@@ -99,12 +107,6 @@ class test_smarthome(object):
|
99
|
107
|
with open(os.path.join(path, "testresults", "testrun_full.tex"), "w") as fh:
|
100
|
108
|
fh.write(template.render(data=self.tcl, details=True))
|
101
|
109
|
|
102
|
|
- def __del__(self):
|
103
|
|
- try:
|
104
|
|
- self.__eval_tcl__()
|
105
|
|
- except:
|
106
|
|
- pass
|
107
|
|
-
|
108
|
110
|
def getmembers(self, prefix=''):
|
109
|
111
|
rv = []
|
110
|
112
|
for name, obj in inspect.getmembers(self):
|