ソースを参照

Test object information added to report

tags/v1.2.0
Dirk Alders 1年前
コミット
0d7b9c3903
9個のファイルの変更130743行の追加3278行の削除
  1. 2
    3
      smart_brain_test.py
  2. 11
    0
      templates/object.tex
  3. 5
    0
      templates/unittest.tex
  4. 108728
    2842
      testresults/testrun.json
  5. バイナリ
      testresults/testrun.pdf
  6. 2257
    59
      testresults/testrun.tex
  7. バイナリ
      testresults/testrun_full.pdf
  8. 19730
    366
      testresults/testrun_full.tex
  9. 10
    8
      tests/all.py

+ 2
- 3
smart_brain_test.py ファイルの表示

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

+ 11
- 0
templates/object.tex ファイルの表示

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 ファイルの表示

10
   {%- include 'system.tex' %}
10
   {%- include 'system.tex' %}
11
 {%- endwith %}
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
 \section{Summary}
19
 \section{Summary}
15
 {%- with testrun = data %}
20
 {%- with testrun = data %}

+ 108728
- 2842
testresults/testrun.json
ファイル差分が大きすぎるため省略します
ファイルの表示


バイナリ
testresults/testrun.pdf ファイルの表示


+ 2257
- 59
testresults/testrun.tex
ファイル差分が大きすぎるため省略します
ファイルの表示


バイナリ
testresults/testrun_full.pdf ファイルの表示


+ 19730
- 366
testresults/testrun_full.tex
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 10
- 8
tests/all.py ファイルの表示

19
 
19
 
20
 
20
 
21
 class test_smarthome(object):
21
 class test_smarthome(object):
22
-    def __init__(self, rooms):
22
+    def __init__(self, rooms, mqtt_client):
23
+        self.mqtt_client = mqtt_client
23
         self.__init__tcl__()
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
         # add testcases for switching devices
27
         # add testcases for switching devices
25
         for name in rooms.getmembers():
28
         for name in rooms.getmembers():
26
             obj = rooms.getobjbyname(name)
29
             obj = rooms.getobjbyname(name)
84
         self.tcl[jsonlog.MAIN_KEY_SYSTEM_INFO] = system_info
87
         self.tcl[jsonlog.MAIN_KEY_SYSTEM_INFO] = system_info
85
         self.tcl["testcase_names"] = report.TCEL_NAMES
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
         path = os.path.abspath(os.path.join(os.path.basename(__file__), '..'))
96
         path = os.path.abspath(os.path.join(os.path.basename(__file__), '..'))
89
 
97
 
90
         with open(os.path.join(path, "testresults", "testrun.json"), "w") as fh:
98
         with open(os.path.join(path, "testresults", "testrun.json"), "w") as fh:
99
         with open(os.path.join(path, "testresults", "testrun_full.tex"), "w") as fh:
107
         with open(os.path.join(path, "testresults", "testrun_full.tex"), "w") as fh:
100
             fh.write(template.render(data=self.tcl, details=True))
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
     def getmembers(self, prefix=''):
110
     def getmembers(self, prefix=''):
109
         rv = []
111
         rv = []
110
         for name, obj in inspect.getmembers(self):
112
         for name, obj in inspect.getmembers(self):

読み込み中…
キャンセル
保存