Parcourir la source

Test object information added to report

tags/v1.2.0
Dirk Alders il y a 1 an
Parent
révision
0d7b9c3903

+ 2
- 3
smart_brain_test.py Voir le fichier

@@ -5,7 +5,6 @@ from simulation.rooms import house
5 5
 import sys
6 6
 from tests.all import test_smarthome
7 7
 
8
-# TODO: Add testobject information (Info dict via mqtt) --> Report
9 8
 # TODO: Extend tests in simulation
10 9
 #         - Switching button functions (gfw_dirk, ffe.sleep)
11 10
 #         - Brightness button functions (gfw.dirk, ffe.sleep)
@@ -27,7 +26,7 @@ if __name__ == "__main__":
27 26
         for c in d.capabilities():
28 27
             COMMANDS.append(name + '.' + c)
29 28
     #
30
-    ts = test_smarthome(h)
29
+    ts = test_smarthome(h, mc)
31 30
     for name in ts.getmembers():
32 31
         d = ts.getobjbyname(name)
33 32
         for c in d.capabilities():
@@ -92,4 +91,4 @@ if __name__ == "__main__":
92 91
         else:
93 92
             h.command(cmd)
94 93
 
95
-    del (ts)
94
+    ts.close()

+ 11
- 0
templates/object.tex Voir le fichier

@@ -0,0 +1,11 @@
1
+{%- import 'macros.tex' as macros %}
2
+\begin{tabu} to \linewidth {lX}
3
+\toprule
4
+{\bf Test object Information}   & \\
5
+\midrule
6
+Test Object Name & {{macros.latex_filter(object_information.app_name)}} \\
7
+Test Object Vesion & {{macros.latex_filter(object_information.version.readable)}} \\
8
+GIT repository & {{macros.latex_filter(object_information.git.url)}}\\
9
+GIT reference & {{macros.latex_filter(object_information.git.ref)}}\\
10
+\bottomrule
11
+\end{tabu}

+ 5
- 0
templates/unittest.tex Voir le fichier

@@ -10,6 +10,11 @@
10 10
   {%- include 'system.tex' %}
11 11
 {%- endwith %}
12 12
 
13
+\section{Test Object Information}
14
+{%- with object_information = data.testobject_information %}
15
+  {%- include 'object.tex' %}
16
+{%- endwith %}
17
+
13 18
 
14 19
 \section{Summary}
15 20
 {%- with testrun = data %}

+ 108728
- 2842
testresults/testrun.json
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


BIN
testresults/testrun.pdf Voir le fichier


+ 2257
- 59
testresults/testrun.tex
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


BIN
testresults/testrun_full.pdf Voir le fichier


+ 19730
- 366
testresults/testrun_full.tex
Fichier diff supprimé car celui-ci est trop grand
Voir le fichier


+ 10
- 8
tests/all.py Voir le fichier

@@ -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):

Chargement…
Annuler
Enregistrer