Testreport from unittest added + Test extension
This commit is contained in:
parent
88cfbb98db
commit
7cf868e886
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
|
testresults
|
||||||
|
|
||||||
# ---> VirtualEnv
|
# ---> VirtualEnv
|
||||||
# Virtualenv
|
# Virtualenv
|
||||||
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
|
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
|
||||||
|
9
.gitmodules
vendored
9
.gitmodules
vendored
@ -10,3 +10,12 @@
|
|||||||
[submodule "task"]
|
[submodule "task"]
|
||||||
path = task
|
path = task
|
||||||
url = https://git.mount-mockery.de/pylib/task.git
|
url = https://git.mount-mockery.de/pylib/task.git
|
||||||
|
[submodule "fstools"]
|
||||||
|
path = fstools
|
||||||
|
url = https://git.mount-mockery.de/pylib/fstools.git
|
||||||
|
[submodule "reqif"]
|
||||||
|
path = reqif
|
||||||
|
url = https://git.mount-mockery.de/pylib/reqif.git
|
||||||
|
[submodule "unittest"]
|
||||||
|
path = unittest
|
||||||
|
url = https://git.mount-mockery.de/pylib/unittest.git
|
||||||
|
39
Makefile
Normal file
39
Makefile
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
OUTDIR=testresults
|
||||||
|
TEXFILE=$(OUTDIR)/testrun.tex
|
||||||
|
PDFFILE=$(OUTDIR)/testrun.pdf
|
||||||
|
TEXFILE_FULL=$(OUTDIR)/testrun_full.tex
|
||||||
|
PDFFILE_FULL=$(OUTDIR)/testrun_full.pdf
|
||||||
|
|
||||||
|
run: test_smoke pdf view pdf_full clean
|
||||||
|
@echo FINISHED...
|
||||||
|
|
||||||
|
run_full: test_full pdf view pdf_full clean
|
||||||
|
@echo FINISHED...
|
||||||
|
|
||||||
|
test_smoke:
|
||||||
|
venv/bin/python smart_brain_test.py test.all.smoke
|
||||||
|
|
||||||
|
test_full:
|
||||||
|
venv/bin/python smart_brain_test.py test.all.full
|
||||||
|
|
||||||
|
pdf:
|
||||||
|
@latexmk -pdf -quiet -pdflatex="pdflatex -interaction=nonstopmode" -output-directory=$(OUTDIR) -use-make $(TEXFILE) > /dev/null
|
||||||
|
|
||||||
|
pdf_full:
|
||||||
|
@latexmk -pdf -quiet -pdflatex="pdflatex -interaction=nonstopmode" -output-directory=$(OUTDIR) -use-make $(TEXFILE_FULL) > /dev/null
|
||||||
|
|
||||||
|
view:
|
||||||
|
@open $(PDFFILE)
|
||||||
|
|
||||||
|
view_full:
|
||||||
|
@open $(PDFFILE_FULL)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
@latexmk -quiet -output-directory=$(OUTDIR) -c $(TEXFILE) > /dev/null
|
||||||
|
@latexmk -quiet -output-directory=$(OUTDIR) -c $(TEXFILE_FULL) > /dev/null
|
||||||
|
@find . -name *~ -type f | xargs rm -f
|
||||||
|
@find . -name __pycache__ -type d | xargs rm -rf
|
||||||
|
|
||||||
|
%:
|
||||||
|
venv/bin/python smart_brain_test.py $@
|
||||||
|
$(MAKE) pdf_full view_full pdf clean
|
1
fstools
Submodule
1
fstools
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit c10e8792abb05671dab6de51cdadda3bf8ead50f
|
1
reqif
Submodule
1
reqif
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit c0e8533af5eeb4dccb6cd8742c936eb456ce6466
|
@ -15,6 +15,8 @@ COLOR_MOTION_SENSOR = colored.fg("dark_orange_3b")
|
|||||||
COLOR_HEATING_VALVE = colored.fg("red")
|
COLOR_HEATING_VALVE = colored.fg("red")
|
||||||
COLOR_REMOTE = colored.fg("green")
|
COLOR_REMOTE = colored.fg("green")
|
||||||
|
|
||||||
|
OUTPUT_ACTIVE = True
|
||||||
|
|
||||||
|
|
||||||
class base(mqtt_base):
|
class base(mqtt_base):
|
||||||
AUTOSEND = True
|
AUTOSEND = True
|
||||||
@ -85,6 +87,7 @@ class base(mqtt_base):
|
|||||||
print("You need to give a numeric parameter not '%s'" % str(value))
|
print("You need to give a numeric parameter not '%s'" % str(value))
|
||||||
|
|
||||||
def print_formatted_light(self, color, state, description, led=False):
|
def print_formatted_light(self, color, state, description, led=False):
|
||||||
|
if OUTPUT_ACTIVE:
|
||||||
if led is True:
|
if led is True:
|
||||||
if state is True:
|
if state is True:
|
||||||
icon = colored.fg('green') + "\u2b24" + color
|
icon = colored.fg('green') + "\u2b24" + color
|
||||||
@ -95,10 +98,12 @@ class base(mqtt_base):
|
|||||||
print(color + 10 * ' ' + icon + 9 * ' ' + self.__devicename__(), description + colored.attr("reset"))
|
print(color + 10 * ' ' + icon + 9 * ' ' + self.__devicename__(), description + colored.attr("reset"))
|
||||||
|
|
||||||
def print_formatted_videv(self, color, state, description):
|
def print_formatted_videv(self, color, state, description):
|
||||||
|
if OUTPUT_ACTIVE:
|
||||||
icon = u'\u25a0' if state is True else u'\u25a1'
|
icon = u'\u25a0' if state is True else u'\u25a1'
|
||||||
print(color + 10 * ' ' + icon + 9 * ' ' + self.__devicename__(), description + colored.attr("reset"))
|
print(color + 10 * ' ' + icon + 9 * ' ' + self.__devicename__(), description + colored.attr("reset"))
|
||||||
|
|
||||||
def print_formatted_percent(self, color, prefix, perc_value, value_str, description):
|
def print_formatted_percent(self, color, prefix, perc_value, value_str, description):
|
||||||
|
if OUTPUT_ACTIVE:
|
||||||
if len(prefix) > 1 or len(value_str) > 7:
|
if len(prefix) > 1 or len(value_str) > 7:
|
||||||
raise ValueError("Length of prefix (%d) > 1 or length of value_str (%d) > 7" % (len(prefix), len(value_str)))
|
raise ValueError("Length of prefix (%d) > 1 or length of value_str (%d) > 7" % (len(prefix), len(value_str)))
|
||||||
print(color + prefix + self.__percent_bar__(perc_value), value_str + (8 - len(value_str))
|
print(color + prefix + self.__percent_bar__(perc_value), value_str + (8 - len(value_str))
|
||||||
@ -365,9 +370,9 @@ class tradfri_light(base):
|
|||||||
|
|
||||||
def __ext_to_int__(self, key, data):
|
def __ext_to_int__(self, key, data):
|
||||||
if key == self.KEY_BRIGHTNESS:
|
if key == self.KEY_BRIGHTNESS:
|
||||||
return round((data - 1) / 2.53, 0)
|
return int(round((data - 1) / 2.53, 0))
|
||||||
elif key == self.KEY_COLOR_TEMP:
|
elif key == self.KEY_COLOR_TEMP:
|
||||||
return round((data - 250) / 20.4, 0)
|
return int(round((data - 250) / 20.4, 0))
|
||||||
else:
|
else:
|
||||||
return super().__ext_to_int__(key, data)
|
return super().__ext_to_int__(key, data)
|
||||||
|
|
||||||
@ -547,12 +552,17 @@ class videv_light(base_videv):
|
|||||||
self.add_callback(self.KEY_COLOR_TEMP, None, self.__send__, True)
|
self.add_callback(self.KEY_COLOR_TEMP, None, self.__send__, True)
|
||||||
self.add_callback(self.KEY_TIMER, None, self.__send__, True)
|
self.add_callback(self.KEY_TIMER, None, self.__send__, True)
|
||||||
|
|
||||||
|
def __ext_to_int__(self, key, data):
|
||||||
|
if key in [self.KEY_BRIGHTNESS, self.KEY_COLOR_TEMP]:
|
||||||
|
return int(data)
|
||||||
|
return super().__ext_to_int__(key, data)
|
||||||
|
|
||||||
def __rx__(self, client, userdata, message):
|
def __rx__(self, client, userdata, message):
|
||||||
value = self.__payload_filter__(message.payload)
|
value = self.__payload_filter__(message.payload)
|
||||||
if message.topic.startswith(self.topic):
|
if message.topic.startswith(self.topic):
|
||||||
targetkey = message.topic.split('/')[-1]
|
targetkey = message.topic.split('/')[-1]
|
||||||
if targetkey in self.keys():
|
if targetkey in self.keys():
|
||||||
self.set(targetkey, value, block_callback=(self.__send__, ))
|
self.set(targetkey, self.__ext_to_int__(targetkey, value), block_callback=(self.__send__, ))
|
||||||
elif targetkey != "__info__":
|
elif targetkey != "__info__":
|
||||||
print("Unknown key %s in %s::%s" % (targetkey, message.topic, self.__class__.__name__))
|
print("Unknown key %s in %s::%s" % (targetkey, message.topic, self.__class__.__name__))
|
||||||
|
|
||||||
|
@ -1,16 +1,20 @@
|
|||||||
import config
|
import config
|
||||||
import logging
|
|
||||||
import mqtt
|
import mqtt
|
||||||
import readline
|
import readline
|
||||||
import report
|
|
||||||
from simulation.rooms import house
|
from simulation.rooms import house
|
||||||
from tests import test_smarthome
|
import sys
|
||||||
import time
|
from tests.all import test_smarthome
|
||||||
|
|
||||||
|
# TODO: Extend tests in simulation
|
||||||
|
# - Switching button functions (gfw_dirk, ffe.sleep)
|
||||||
|
# - Brightness button functions (gfw.dirk, ffe.sleep)
|
||||||
|
# - Synch functions of amplifier with spotify, mpd
|
||||||
|
# - Remote actions after amplifier on
|
||||||
|
# - Heating functionality (extended: mode switch off by other function, timer)
|
||||||
|
# - Circulation pump (Extend Timer)
|
||||||
|
# - Stairways (Extend Motion sensor and Timer)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
report.stdoutLoggingConfigure(
|
|
||||||
((config.APP_NAME, logging.WARNING), ), report.SHORT_FMT)
|
|
||||||
#
|
|
||||||
mc = mqtt.mqtt_client(host=config.MQTT_SERVER, port=config.MQTT_PORT, username=config.MQTT_USER,
|
mc = mqtt.mqtt_client(host=config.MQTT_SERVER, port=config.MQTT_PORT, username=config.MQTT_USER,
|
||||||
password=config.MQTT_PASSWORD, name=config.APP_NAME + '_simulation')
|
password=config.MQTT_PASSWORD, name=config.APP_NAME + '_simulation')
|
||||||
#
|
#
|
||||||
@ -61,11 +65,10 @@ if __name__ == "__main__":
|
|||||||
else:
|
else:
|
||||||
state -= 1
|
state -= 1
|
||||||
|
|
||||||
|
if len(sys.argv) == 1:
|
||||||
readline.parse_and_bind("tab: complete")
|
readline.parse_and_bind("tab: complete")
|
||||||
readline.set_completer(completer)
|
readline.set_completer(completer)
|
||||||
time.sleep(0.3)
|
|
||||||
print("\nEnter command: ")
|
print("\nEnter command: ")
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
userfeedback = input('')
|
userfeedback = input('')
|
||||||
command = userfeedback.split(' ')[0]
|
command = userfeedback.split(' ')[0]
|
||||||
@ -75,11 +78,17 @@ if __name__ == "__main__":
|
|||||||
print("Help is not yet implemented!")
|
print("Help is not yet implemented!")
|
||||||
elif userfeedback.startswith("test"):
|
elif userfeedback.startswith("test"):
|
||||||
ts.command(userfeedback)
|
ts.command(userfeedback)
|
||||||
elif userfeedback == 'test.smoke':
|
|
||||||
ts.smoke()
|
|
||||||
elif command in COMMANDS[2:]:
|
elif command in COMMANDS[2:]:
|
||||||
h.command(userfeedback)
|
h.command(userfeedback)
|
||||||
elif userfeedback != "":
|
elif userfeedback != "":
|
||||||
print("Unknown command!")
|
print("Unknown command!")
|
||||||
else:
|
else:
|
||||||
print()
|
print()
|
||||||
|
else:
|
||||||
|
cmd = sys.argv[1]
|
||||||
|
if cmd.startswith('test'):
|
||||||
|
ts.command(cmd)
|
||||||
|
else:
|
||||||
|
h.command(cmd)
|
||||||
|
|
||||||
|
del (ts)
|
||||||
|
11
templates/macros.tex
Normal file
11
templates/macros.tex
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{%- macro latex_filter(text) -%}{{ text.replace('\\', '/').replace('%', '\\%').replace('/xc2/xb0', '$^\circ$').replace('"', '\'').replace('/', '/\\allowbreak ').replace('&', '\\allowbreak \\&').replace('_', '\\_').replace('->', '$\\rightarrow$').replace('<-', '$\\leftarrow$').replace('=>', '$\\Rightarrow$').replace('<=', '$\\leq$').replace('>=', '$\\geq$').replace('<', '$<$').replace('>', '$>$').replace('{', '\{').replace('}', '\}').replace('#', '\\#')}}
|
||||||
|
{%- endmacro -%}
|
||||||
|
|
||||||
|
{%- macro color_by_level(level) -%}{% if level <= 10 %}black{% else %}{% if level <= 20 %}green{% else %}{% if level <= 30 %}orange{% else %}red{% endif %}{% endif %}{% endif %}
|
||||||
|
{%- endmacro -%}
|
||||||
|
|
||||||
|
{%- macro bg_by_levelno(level) -%}{% if level <= 10 %}0.8 0.8 0.8{% else %}{% if level <= 20 %}0.8 0.95 0.8{% else %}{% if level <= 30 %}1 0.75 0.45{% else %}0.95 0.8 0.8{% endif %}{% endif %}{% endif %}
|
||||||
|
{%- endmacro -%}
|
||||||
|
|
||||||
|
{%- macro result(level) -%}{% if level <= 10 %}Info{% else %}{% if level <= 20 %}\textcolor{green}{Success}{% else %}{% if level <= 30 %}\textcolor{orange}{Warning}{% else %}\textcolor{red}{Failed}{% endif %}{% endif %}{% endif %}
|
||||||
|
{%- endmacro -%}
|
36
templates/report_testcase.tex
Normal file
36
templates/report_testcase.tex
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
{%- import 'macros.tex' as macros %}
|
||||||
|
\paragraph{Testsummary}\mbox{}\\
|
||||||
|
This test was passed with the state: {\bf {{ macros.result(testcase.levelno) }}}.
|
||||||
|
\begin{longtabu} to \linewidth {lX}
|
||||||
|
\toprule
|
||||||
|
Caller: & {{ macros.latex_filter(testcase.pathname) }} ({{ "%d" % testcase.lineno }})\\
|
||||||
|
Start-Time: & {{ macros.latex_filter(testcase.time_start) }}\\
|
||||||
|
Finished-Time: & {{ macros.latex_filter(testcase.time_finished) }}\\
|
||||||
|
Time-Consumption & {{ '%.3fs' % (testcase.time_consumption) }}\\
|
||||||
|
\midrule
|
||||||
|
\multicolumn{2}{l}{\bf{Testresults:}}\\
|
||||||
|
\midrule
|
||||||
|
{%- for tLogger in testcase.testcaseLogger %}
|
||||||
|
\bf{\,{{ macros.result(tLogger.levelno) }} } & {{ macros.latex_filter(tLogger.message) }}\\
|
||||||
|
{%- endfor %}
|
||||||
|
\bottomrule
|
||||||
|
\end{longtabu}
|
||||||
|
|
||||||
|
{% if details== true %}
|
||||||
|
\paragraph{Testdetails}\mbox{}\\
|
||||||
|
{%- for tLogger in testcase.testcaseLogger %}
|
||||||
|
\begin{tabu} to \linewidth {lX}
|
||||||
|
\toprule
|
||||||
|
{\bf {{ macros.result(tLogger.levelno) }} } & {{ macros.latex_filter(tLogger.message) }}\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabu}
|
||||||
|
{%- for mLogger in tLogger.moduleLogger %}
|
||||||
|
\definecolor{shadecolor}{rgb}{ {{macros.bg_by_levelno(mLogger.levelno) }} }\begin{modulelog}[breaklines=true, breakanywhere=true]
|
||||||
|
{{ mLogger.message }}
|
||||||
|
\end{modulelog}
|
||||||
|
\vspace*{-0.225cm}\pagebreak[1]
|
||||||
|
{%- endfor %}
|
||||||
|
|
||||||
|
\vspace*{2.5ex}
|
||||||
|
{%- endfor %}
|
||||||
|
{% endif %}
|
13
templates/run_statistic.tex
Normal file
13
templates/run_statistic.tex
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{%- import 'macros.tex' as macros %}
|
||||||
|
\begin{tabu} to \linewidth {lX}
|
||||||
|
\toprule
|
||||||
|
Number of tests & {{ "{\\bf %d}" % testrun.number_of_tests }}\\
|
||||||
|
Number of successfull tests & {{ "{\\bf %d}" % testrun.number_of_successfull_tests }}\\
|
||||||
|
Number of possibly failed tests & \textcolor{% if testrun.number_of_possibly_failed_tests > 0%}{orange}{% else %}{black}{% endif %}{{ "{\\bf %d}" % testrun.number_of_possibly_failed_tests }}\\
|
||||||
|
Number of failed tests & \textcolor{% if testrun.number_of_failed_tests > 0%}{red}{% else %}{black}{% endif %}{{ "{\\bf %d}" % testrun.number_of_failed_tests }}\\
|
||||||
|
\midrule
|
||||||
|
Executionlevel & {{ macros.latex_filter(testrun.testcase_names.get('%d' % testrun.testcase_execution_level, 'unknown')) }}\\
|
||||||
|
Time consumption & {{ '%.3fs' % testrun.time_consumption }}\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabu}
|
||||||
|
|
12
templates/system.tex
Normal file
12
templates/system.tex
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{%- import 'macros.tex' as macros %}
|
||||||
|
\begin{tabu} to \linewidth {lX}
|
||||||
|
\toprule
|
||||||
|
{\bf System Information} & \\
|
||||||
|
\midrule
|
||||||
|
{%- for key in system_information %}
|
||||||
|
{%- if key != "Description" %}
|
||||||
|
{{macros.latex_filter(key)}} & {{macros.latex_filter(data.system_information[key])}} \\
|
||||||
|
{%- endif %}
|
||||||
|
{%- endfor %}
|
||||||
|
\bottomrule
|
||||||
|
\end{tabu}
|
49
templates/unittest.tex
Normal file
49
templates/unittest.tex
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
{%- import 'macros.tex' as macros %}
|
||||||
|
{%- include 'unittest_head.tex' %}
|
||||||
|
{%- include 'unittest_titlepage.tex' %}
|
||||||
|
|
||||||
|
\tableofcontents
|
||||||
|
\newpage
|
||||||
|
|
||||||
|
\section{Test System Information}
|
||||||
|
{%- with system_information = data.system_information %}
|
||||||
|
{%- include 'system.tex' %}
|
||||||
|
{%- endwith %}
|
||||||
|
|
||||||
|
|
||||||
|
\section{Summary}
|
||||||
|
{%- with testrun = data %}
|
||||||
|
{%- include 'run_statistic.tex' %}
|
||||||
|
{%- endwith %}
|
||||||
|
|
||||||
|
{% if data.number_of_failed_tests > 0 or data.number_of_possibly_failed_tests > 0%}
|
||||||
|
\section{\textcolor{red}{Testcases (Failed)}}
|
||||||
|
{%- for test_name in data.uid_list_sorted %}
|
||||||
|
{% with testcase = data.testcases[test_name] %}
|
||||||
|
{% if testcase.levelno > 20 %}
|
||||||
|
\subsection{ {{macros.latex_filter(testcase.message)}} }
|
||||||
|
{% with details = true %}
|
||||||
|
{% include 'report_testcase.tex' %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
{% if data.number_of_successfull_tests > 0 %}
|
||||||
|
\section{\textcolor{green}{Testcases (Success)}}
|
||||||
|
{%- for test_name in data.uid_list_sorted %}
|
||||||
|
{% with testcase = data.testcases[test_name] %}
|
||||||
|
{% if testcase.levelno <= 20 %}
|
||||||
|
\subsection{ {{macros.latex_filter(testcase.message)}} }
|
||||||
|
{% with details = details %}
|
||||||
|
{% include 'report_testcase.tex' %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endif %}
|
||||||
|
{% endwith %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
{% include 'unittest_foot.tex' %}
|
1
templates/unittest_foot.tex
Normal file
1
templates/unittest_foot.tex
Normal file
@ -0,0 +1 @@
|
|||||||
|
\end{document}
|
89
templates/unittest_head.tex
Normal file
89
templates/unittest_head.tex
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
{%- import 'macros.tex' as macros %}
|
||||||
|
\documentclass[a4paper]{article}
|
||||||
|
%\documentclass[a4paper,landscape]{article}
|
||||||
|
|
||||||
|
\renewcommand{\familydefault}{\sfdefault}
|
||||||
|
\usepackage[table]{xcolor}
|
||||||
|
\definecolor{orange}{rgb}{1, 0.7, 0}
|
||||||
|
\definecolor{lightgrey}{rgb}{0.925, 0.925, 0.925}
|
||||||
|
|
||||||
|
\setlength{\topmargin}{-3cm}
|
||||||
|
\setlength{\oddsidemargin}{-0.5cm}
|
||||||
|
\setlength{\evensidemargin}{0cm}
|
||||||
|
\setlength{\textwidth}{17.5cm}
|
||||||
|
\setlength{\textheight}{24.5cm}
|
||||||
|
%\setlength{\textwidth}{25cm}
|
||||||
|
%\setlength{\textheight}{15cm}
|
||||||
|
\setlength{\headheight}{84pt}
|
||||||
|
|
||||||
|
\usepackage{fancyvrb}
|
||||||
|
\usepackage{fvextra}
|
||||||
|
%\usepackage{framed,color}
|
||||||
|
%\newenvironment{modulelog}{\snugshade\Verbatim}{\endVerbatim\endsnugshade}
|
||||||
|
\usepackage{adjustbox}
|
||||||
|
\newenvironment{modulelog}%
|
||||||
|
{\par\noindent\adjustbox{margin=0ex,bgcolor=shadecolor,margin=0ex}\bgroup\varwidth\linewidth\Verbatim}%
|
||||||
|
{\endVerbatim\endvarwidth\egroup}
|
||||||
|
%\usepackage{xcolor}
|
||||||
|
|
||||||
|
\renewcommand{\baselinestretch}{1,2}
|
||||||
|
\setlength{\parindent}{0pt}
|
||||||
|
\setlength{\parskip}{9pt plus3pt minus3pt}
|
||||||
|
|
||||||
|
\usepackage{listings}
|
||||||
|
\usepackage{color}
|
||||||
|
\definecolor{bg-partially-covered}{rgb}{1,1,0.6} % light-yellow
|
||||||
|
\definecolor{bg-uncovered}{rgb}{1,0.8,0.8} % light-red
|
||||||
|
\definecolor{bg-covered}{rgb}{0.95,1,0.95} % very light-green
|
||||||
|
\definecolor{bg-clean}{rgb}{1,1,1} % white
|
||||||
|
\definecolor{mygreen}{rgb}{0,0.6,0}
|
||||||
|
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
|
||||||
|
\definecolor{mymauve}{rgb}{0.58,0,0.82}
|
||||||
|
\lstset{ %
|
||||||
|
backgroundcolor=\color{white}, % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}; should come as last argument
|
||||||
|
basicstyle=\footnotesize, % the size of the fonts that are used for the code
|
||||||
|
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
|
||||||
|
breaklines=true, % sets automatic line breaking
|
||||||
|
captionpos=b, % sets the caption-position to bottom
|
||||||
|
commentstyle=\color{mygreen}, % comment style
|
||||||
|
deletekeywords={...}, % if you want to delete keywords from the given language
|
||||||
|
escapeinside={\%*}{*)}, % if you want to add LaTeX within your code
|
||||||
|
extendedchars=true, % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
|
||||||
|
frame=none, % adds a frame around the code
|
||||||
|
keepspaces=true, % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
|
||||||
|
keywordstyle=\color{blue}, % keyword style
|
||||||
|
language=Octave, % the language of the code
|
||||||
|
morekeywords={*,...}, % if you want to add more keywords to the set
|
||||||
|
numbers=left, % where to put the line-numbers; possible values are (none, left, right)
|
||||||
|
numbersep=5pt, % how far the line-numbers are from the code
|
||||||
|
numberstyle=\tiny\color{mygray}, % the style that is used for the line-numbers
|
||||||
|
rulecolor=\color{black}, % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
|
||||||
|
showlines=true,
|
||||||
|
showspaces=false, % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
|
||||||
|
showstringspaces=false, % underline spaces within strings only
|
||||||
|
showtabs=false, % show tabs within strings adding particular underscores
|
||||||
|
stepnumber=1, % the step between two line-numbers. If it's 1, each line will be numbered
|
||||||
|
stringstyle=\color{mymauve}, % string literal style
|
||||||
|
tabsize=2, % sets default tabsize to 2 spaces
|
||||||
|
}
|
||||||
|
\usepackage{hyperref}
|
||||||
|
\usepackage{longtable}[=v4.13]
|
||||||
|
\usepackage{tabu}
|
||||||
|
\usepackage{multicol}
|
||||||
|
\usepackage{booktabs}
|
||||||
|
\usepackage{graphicx}
|
||||||
|
\usepackage{lastpage} % for the number of the last page in the document
|
||||||
|
\usepackage{fancyhdr}
|
||||||
|
|
||||||
|
\fancyhf{}
|
||||||
|
\renewcommand{\headrulewidth}{0pt}
|
||||||
|
\renewcommand{\footrulewidth}{0pt}
|
||||||
|
\lhead{\textcolor{gray}{}}
|
||||||
|
\chead{\textcolor{gray}{ Unittest for {\tt smart\_brain }}}
|
||||||
|
\rhead{\textcolor{gray}{}}
|
||||||
|
\lfoot{\textcolor{gray}{}}
|
||||||
|
\cfoot{\textcolor{gray}{}}
|
||||||
|
\rfoot{\textcolor{gray}{\thepage\,/ \pageref{LastPage}}}
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
|
14
templates/unittest_titlepage.tex
Normal file
14
templates/unittest_titlepage.tex
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{%- import 'macros.tex' as macros %}
|
||||||
|
\begin{titlepage}
|
||||||
|
\date{\today}
|
||||||
|
\title{
|
||||||
|
Unittest for {\tt smart\_brain }
|
||||||
|
}
|
||||||
|
\date{\today}
|
||||||
|
\maketitle
|
||||||
|
\thispagestyle{empty}
|
||||||
|
\newpage
|
||||||
|
\end{titlepage}
|
||||||
|
|
||||||
|
\setcounter{page}{1}
|
||||||
|
\pagestyle{fancy}
|
6409
testresults/testrun.json
Normal file
6409
testresults/testrun.json
Normal file
File diff suppressed because it is too large
Load Diff
BIN
testresults/testrun.pdf
Normal file
BIN
testresults/testrun.pdf
Normal file
Binary file not shown.
304
testresults/testrun.tex
Normal file
304
testresults/testrun.tex
Normal file
@ -0,0 +1,304 @@
|
|||||||
|
|
||||||
|
\documentclass[a4paper]{article}
|
||||||
|
%\documentclass[a4paper,landscape]{article}
|
||||||
|
|
||||||
|
\renewcommand{\familydefault}{\sfdefault}
|
||||||
|
\usepackage[table]{xcolor}
|
||||||
|
\definecolor{orange}{rgb}{1, 0.7, 0}
|
||||||
|
\definecolor{lightgrey}{rgb}{0.925, 0.925, 0.925}
|
||||||
|
|
||||||
|
\setlength{\topmargin}{-3cm}
|
||||||
|
\setlength{\oddsidemargin}{-0.5cm}
|
||||||
|
\setlength{\evensidemargin}{0cm}
|
||||||
|
\setlength{\textwidth}{17.5cm}
|
||||||
|
\setlength{\textheight}{24.5cm}
|
||||||
|
%\setlength{\textwidth}{25cm}
|
||||||
|
%\setlength{\textheight}{15cm}
|
||||||
|
\setlength{\headheight}{84pt}
|
||||||
|
|
||||||
|
\usepackage{fancyvrb}
|
||||||
|
\usepackage{fvextra}
|
||||||
|
%\usepackage{framed,color}
|
||||||
|
%\newenvironment{modulelog}{\snugshade\Verbatim}{\endVerbatim\endsnugshade}
|
||||||
|
\usepackage{adjustbox}
|
||||||
|
\newenvironment{modulelog}%
|
||||||
|
{\par\noindent\adjustbox{margin=0ex,bgcolor=shadecolor,margin=0ex}\bgroup\varwidth\linewidth\Verbatim}%
|
||||||
|
{\endVerbatim\endvarwidth\egroup}
|
||||||
|
%\usepackage{xcolor}
|
||||||
|
|
||||||
|
\renewcommand{\baselinestretch}{1,2}
|
||||||
|
\setlength{\parindent}{0pt}
|
||||||
|
\setlength{\parskip}{9pt plus3pt minus3pt}
|
||||||
|
|
||||||
|
\usepackage{listings}
|
||||||
|
\usepackage{color}
|
||||||
|
\definecolor{bg-partially-covered}{rgb}{1,1,0.6} % light-yellow
|
||||||
|
\definecolor{bg-uncovered}{rgb}{1,0.8,0.8} % light-red
|
||||||
|
\definecolor{bg-covered}{rgb}{0.95,1,0.95} % very light-green
|
||||||
|
\definecolor{bg-clean}{rgb}{1,1,1} % white
|
||||||
|
\definecolor{mygreen}{rgb}{0,0.6,0}
|
||||||
|
\definecolor{mygray}{rgb}{0.5,0.5,0.5}
|
||||||
|
\definecolor{mymauve}{rgb}{0.58,0,0.82}
|
||||||
|
\lstset{ %
|
||||||
|
backgroundcolor=\color{white}, % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}; should come as last argument
|
||||||
|
basicstyle=\footnotesize, % the size of the fonts that are used for the code
|
||||||
|
breakatwhitespace=false, % sets if automatic breaks should only happen at whitespace
|
||||||
|
breaklines=true, % sets automatic line breaking
|
||||||
|
captionpos=b, % sets the caption-position to bottom
|
||||||
|
commentstyle=\color{mygreen}, % comment style
|
||||||
|
deletekeywords={...}, % if you want to delete keywords from the given language
|
||||||
|
escapeinside={\%*}{*)}, % if you want to add LaTeX within your code
|
||||||
|
extendedchars=true, % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
|
||||||
|
frame=none, % adds a frame around the code
|
||||||
|
keepspaces=true, % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
|
||||||
|
keywordstyle=\color{blue}, % keyword style
|
||||||
|
language=Octave, % the language of the code
|
||||||
|
morekeywords={*,...}, % if you want to add more keywords to the set
|
||||||
|
numbers=left, % where to put the line-numbers; possible values are (none, left, right)
|
||||||
|
numbersep=5pt, % how far the line-numbers are from the code
|
||||||
|
numberstyle=\tiny\color{mygray}, % the style that is used for the line-numbers
|
||||||
|
rulecolor=\color{black}, % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
|
||||||
|
showlines=true,
|
||||||
|
showspaces=false, % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
|
||||||
|
showstringspaces=false, % underline spaces within strings only
|
||||||
|
showtabs=false, % show tabs within strings adding particular underscores
|
||||||
|
stepnumber=1, % the step between two line-numbers. If it's 1, each line will be numbered
|
||||||
|
stringstyle=\color{mymauve}, % string literal style
|
||||||
|
tabsize=2, % sets default tabsize to 2 spaces
|
||||||
|
}
|
||||||
|
\usepackage{hyperref}
|
||||||
|
\usepackage{longtable}[=v4.13]
|
||||||
|
\usepackage{tabu}
|
||||||
|
\usepackage{multicol}
|
||||||
|
\usepackage{booktabs}
|
||||||
|
\usepackage{graphicx}
|
||||||
|
\usepackage{lastpage} % for the number of the last page in the document
|
||||||
|
\usepackage{fancyhdr}
|
||||||
|
|
||||||
|
\fancyhf{}
|
||||||
|
\renewcommand{\headrulewidth}{0pt}
|
||||||
|
\renewcommand{\footrulewidth}{0pt}
|
||||||
|
\lhead{\textcolor{gray}{}}
|
||||||
|
\chead{\textcolor{gray}{ Unittest for {\tt smart\_brain }}}
|
||||||
|
\rhead{\textcolor{gray}{}}
|
||||||
|
\lfoot{\textcolor{gray}{}}
|
||||||
|
\cfoot{\textcolor{gray}{}}
|
||||||
|
\rfoot{\textcolor{gray}{\thepage\,/ \pageref{LastPage}}}
|
||||||
|
|
||||||
|
\begin{document}
|
||||||
|
|
||||||
|
\begin{titlepage}
|
||||||
|
\date{\today}
|
||||||
|
\title{
|
||||||
|
Unittest for {\tt smart\_brain }
|
||||||
|
}
|
||||||
|
\date{\today}
|
||||||
|
\maketitle
|
||||||
|
\thispagestyle{empty}
|
||||||
|
\newpage
|
||||||
|
\end{titlepage}
|
||||||
|
|
||||||
|
\setcounter{page}{1}
|
||||||
|
\pagestyle{fancy}
|
||||||
|
|
||||||
|
\tableofcontents
|
||||||
|
\newpage
|
||||||
|
|
||||||
|
\section{Test System Information}
|
||||||
|
\begin{tabu} to \linewidth {lX}
|
||||||
|
\toprule
|
||||||
|
{\bf System Information} & \\
|
||||||
|
\midrule
|
||||||
|
Architecture & 64bit \\
|
||||||
|
Machine & x86\_64 \\
|
||||||
|
Hostname & ahorn \\
|
||||||
|
Distribution & Linux Mint 21.1 (vera) \\
|
||||||
|
System & Linux \\
|
||||||
|
Kernel & 5.15.0-58-generic (\#64-Ubuntu SMP Thu Jan 5 11:43:13 UTC 2023) \\
|
||||||
|
Username & dirk \\
|
||||||
|
Path & /\allowbreak home/\allowbreak dirk/\allowbreak my\_repositories/\allowbreak smarthome/\allowbreak smart\_brain\_test/\allowbreak all.py \\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabu}
|
||||||
|
|
||||||
|
|
||||||
|
\section{Summary}
|
||||||
|
\begin{tabu} to \linewidth {lX}
|
||||||
|
\toprule
|
||||||
|
Number of tests & {\bf 5}\\
|
||||||
|
Number of successfull tests & {\bf 5}\\
|
||||||
|
Number of possibly failed tests & \textcolor{black}{\bf 0}\\
|
||||||
|
Number of failed tests & \textcolor{black}{\bf 0}\\
|
||||||
|
\midrule
|
||||||
|
Executionlevel & unknown\\
|
||||||
|
Time consumption & 4.510s\\
|
||||||
|
\bottomrule
|
||||||
|
\end{tabu}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\section{\textcolor{green}{Testcases (Success)}}
|
||||||
|
|
||||||
|
|
||||||
|
\subsection{ Away mode test: zigbee/\allowbreak gfw/\allowbreak dirk/\allowbreak heating\_valve }
|
||||||
|
|
||||||
|
|
||||||
|
\paragraph{Testsummary}\mbox{}\\
|
||||||
|
This test was passed with the state: {\bf \textcolor{green}{Success}}.
|
||||||
|
\begin{longtabu} to \linewidth {lX}
|
||||||
|
\toprule
|
||||||
|
Caller: & /\allowbreak home/\allowbreak dirk/\allowbreak my\_repositories/\allowbreak smarthome/\allowbreak smart\_brain\_test/\allowbreak tests/\allowbreak heating.py (84)\\
|
||||||
|
Start-Time: & 2023-02-09 07:53:02,566\\
|
||||||
|
Finished-Time: & 2023-02-09 07:53:03,468\\
|
||||||
|
Time-Consumption & 0.902s\\
|
||||||
|
\midrule
|
||||||
|
\multicolumn{2}{l}{\bf{Testresults:}}\\
|
||||||
|
\midrule
|
||||||
|
\bf{\,Info } & Setting preconditions (Default setpoint)\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Away mode is correct (Content False and Type is $<$class 'bool'$>$).\\
|
||||||
|
\bf{\,Info } & Activating away mode\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Away mode is correct (Content True and Type is $<$class 'bool'$>$).\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Temperature setpoint is correct (Content 20 and Type is $<$class 'int'$>$).\\
|
||||||
|
\bf{\,Info } & Deactivating away mode\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Away mode is correct (Content False and Type is $<$class 'bool'$>$).\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Temperature setpoint is correct (Content 25 and Type is $<$class 'int'$>$).\\
|
||||||
|
\bottomrule
|
||||||
|
\end{longtabu}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\subsection{ Boost mode test: zigbee/\allowbreak gfw/\allowbreak dirk/\allowbreak heating\_valve }
|
||||||
|
|
||||||
|
|
||||||
|
\paragraph{Testsummary}\mbox{}\\
|
||||||
|
This test was passed with the state: {\bf \textcolor{green}{Success}}.
|
||||||
|
\begin{longtabu} to \linewidth {lX}
|
||||||
|
\toprule
|
||||||
|
Caller: & /\allowbreak home/\allowbreak dirk/\allowbreak my\_repositories/\allowbreak smarthome/\allowbreak smart\_brain\_test/\allowbreak tests/\allowbreak heating.py (107)\\
|
||||||
|
Start-Time: & 2023-02-09 07:53:03,468\\
|
||||||
|
Finished-Time: & 2023-02-09 07:53:04,370\\
|
||||||
|
Time-Consumption & 0.902s\\
|
||||||
|
\midrule
|
||||||
|
\multicolumn{2}{l}{\bf{Testresults:}}\\
|
||||||
|
\midrule
|
||||||
|
\bf{\,Info } & Setting preconditions (Default setpoint)\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Boost timer is correct (Content 0 and Type is $<$class 'int'$>$).\\
|
||||||
|
\bf{\,Info } & Activating boost mode\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Boost timer is greater expectation (Content 900 and Type is $<$class 'int'$>$).\\
|
||||||
|
\bf{\,Info } & Setting postconditions (Default setpoint)\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Boost timer is correct (Content 0 and Type is $<$class 'int'$>$).\\
|
||||||
|
\bottomrule
|
||||||
|
\end{longtabu}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\subsection{ Default temperature test for device and virtual device: zigbee/\allowbreak gfw/\allowbreak dirk/\allowbreak heating\_valve }
|
||||||
|
|
||||||
|
|
||||||
|
\paragraph{Testsummary}\mbox{}\\
|
||||||
|
This test was passed with the state: {\bf \textcolor{green}{Success}}.
|
||||||
|
\begin{longtabu} to \linewidth {lX}
|
||||||
|
\toprule
|
||||||
|
Caller: & /\allowbreak home/\allowbreak dirk/\allowbreak my\_repositories/\allowbreak smarthome/\allowbreak smart\_brain\_test/\allowbreak tests/\allowbreak heating.py (41)\\
|
||||||
|
Start-Time: & 2023-02-09 07:53:04,370\\
|
||||||
|
Finished-Time: & 2023-02-09 07:53:04,972\\
|
||||||
|
Time-Consumption & 0.601s\\
|
||||||
|
\midrule
|
||||||
|
\multicolumn{2}{l}{\bf{Testresults:}}\\
|
||||||
|
\midrule
|
||||||
|
\bf{\,Info } & Setting preconditions (Valve setpoint to 20.0)\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Valve temperature setpoint (is not default temperature) is correct (Content True and Type is $<$class 'bool'$>$).\\
|
||||||
|
\bf{\,Info } & Triggering set to default temperature (25.0)\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Valve temperature setpoint is correct (Content 25 and Type is $<$class 'int'$>$).\\
|
||||||
|
\bottomrule
|
||||||
|
\end{longtabu}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\subsection{ Summer mode test: zigbee/\allowbreak gfw/\allowbreak dirk/\allowbreak heating\_valve }
|
||||||
|
|
||||||
|
|
||||||
|
\paragraph{Testsummary}\mbox{}\\
|
||||||
|
This test was passed with the state: {\bf \textcolor{green}{Success}}.
|
||||||
|
\begin{longtabu} to \linewidth {lX}
|
||||||
|
\toprule
|
||||||
|
Caller: & /\allowbreak home/\allowbreak dirk/\allowbreak my\_repositories/\allowbreak smarthome/\allowbreak smart\_brain\_test/\allowbreak tests/\allowbreak heating.py (61)\\
|
||||||
|
Start-Time: & 2023-02-09 07:53:04,972\\
|
||||||
|
Finished-Time: & 2023-02-09 07:53:05,874\\
|
||||||
|
Time-Consumption & 0.902s\\
|
||||||
|
\midrule
|
||||||
|
\multicolumn{2}{l}{\bf{Testresults:}}\\
|
||||||
|
\midrule
|
||||||
|
\bf{\,Info } & Setting preconditions (Default setpoint)\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Summer mode is correct (Content False and Type is $<$class 'bool'$>$).\\
|
||||||
|
\bf{\,Info } & Activating summer mode\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Summer mode is correct (Content True and Type is $<$class 'bool'$>$).\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Temperature setpoint is correct (Content 5 and Type is $<$class 'int'$>$).\\
|
||||||
|
\bf{\,Info } & Deactivating summer mode\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Summer mode is correct (Content False and Type is $<$class 'bool'$>$).\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Temperature setpoint is correct (Content 25 and Type is $<$class 'int'$>$).\\
|
||||||
|
\bottomrule
|
||||||
|
\end{longtabu}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\subsection{ User temperature setpoint test for device and virtual device: zigbee/\allowbreak gfw/\allowbreak dirk/\allowbreak heating\_valve }
|
||||||
|
|
||||||
|
|
||||||
|
\paragraph{Testsummary}\mbox{}\\
|
||||||
|
This test was passed with the state: {\bf \textcolor{green}{Success}}.
|
||||||
|
\begin{longtabu} to \linewidth {lX}
|
||||||
|
\toprule
|
||||||
|
Caller: & /\allowbreak home/\allowbreak dirk/\allowbreak my\_repositories/\allowbreak smarthome/\allowbreak smart\_brain\_test/\allowbreak tests/\allowbreak heating.py (17)\\
|
||||||
|
Start-Time: & 2023-02-09 07:53:05,874\\
|
||||||
|
Finished-Time: & 2023-02-09 07:53:07,076\\
|
||||||
|
Time-Consumption & 1.203s\\
|
||||||
|
\midrule
|
||||||
|
\multicolumn{2}{l}{\bf{Testresults:}}\\
|
||||||
|
\midrule
|
||||||
|
\bf{\,Info } & Changing valve temperature setpoint to '20.0'\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Virtual device valve temperature is correct (Content 20 and Type is $<$class 'int'$>$).\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Virtual device user temperature is correct (Content 20 and Type is $<$class 'int'$>$).\\
|
||||||
|
\bf{\,Info } & Changing videv user temperature setpoint to '25.0'\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Valve device temperature setpoint is correct (Content 25 and Type is $<$class 'int'$>$).\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Virtual device valve temperature is correct (Content 25 and Type is $<$class 'int'$>$).\\
|
||||||
|
\bf{\,Info } & Changing valve temperature setpoint to '20.0'\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Virtual device valve temperature is correct (Content 20 and Type is $<$class 'int'$>$).\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Virtual device user temperature is correct (Content 20 and Type is $<$class 'int'$>$).\\
|
||||||
|
\bf{\,Info } & Changing videv user temperature setpoint to '25.0'\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Valve device temperature setpoint is correct (Content 25 and Type is $<$class 'int'$>$).\\
|
||||||
|
\bf{\,\textcolor{green}{Success} } & Virtual device valve temperature is correct (Content 25 and Type is $<$class 'int'$>$).\\
|
||||||
|
\bottomrule
|
||||||
|
\end{longtabu}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\end{document}
|
BIN
testresults/testrun_full.pdf
Normal file
BIN
testresults/testrun_full.pdf
Normal file
Binary file not shown.
1328
testresults/testrun_full.tex
Normal file
1328
testresults/testrun_full.tex
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,137 +1,26 @@
|
|||||||
import colored
|
import report
|
||||||
import config
|
import simulation.devices
|
||||||
import inspect
|
from unittest.test import equivalency_chk
|
||||||
import simulation.devices as devices
|
|
||||||
import time
|
|
||||||
|
|
||||||
|
|
||||||
DT_TOGGLE = 0.3
|
DT_TOGGLE = 0.3
|
||||||
|
|
||||||
|
|
||||||
TEST_FULL = 'full'
|
class test_collection(object):
|
||||||
TEST_SMOKE = 'smoke'
|
|
||||||
#
|
|
||||||
COLOR_SUCCESS = colored.fg("light_green")
|
|
||||||
COLOR_FAIL = colored.fg("light_red")
|
|
||||||
|
|
||||||
|
|
||||||
class test_smarthome(object):
|
|
||||||
def __init__(self, rooms):
|
|
||||||
# add testcases for switching devices
|
|
||||||
for name in rooms.getmembers():
|
|
||||||
obj = rooms.getobjbyname(name)
|
|
||||||
if obj.__class__.__name__ == "videv_light":
|
|
||||||
common_name = '.'.join(name.split('.')[:-1]) + '.' + name.split('.')[-1][6:]
|
|
||||||
try:
|
|
||||||
li_device = rooms.getobjbyname(common_name + '_zigbee') if obj.enable_brightness or obj.enable_color_temp else None
|
|
||||||
except AttributeError:
|
|
||||||
li_device = rooms.getobjbyname(common_name + '_zigbee_1') if obj.enable_brightness or obj.enable_color_temp else None
|
|
||||||
try:
|
|
||||||
sw_device = rooms.getobjbyname(common_name) if obj.enable_state else None
|
|
||||||
except AttributeError:
|
|
||||||
# must be a device without switching device
|
|
||||||
sw_device = li_device
|
|
||||||
setattr(self, common_name.replace('.', '_'), testcase_light(obj, sw_device, li_device))
|
|
||||||
# add testcases for heating devices
|
|
||||||
for name in rooms.getmembers():
|
|
||||||
obj = rooms.getobjbyname(name)
|
|
||||||
if obj.__class__.__name__ == "videv_heating":
|
|
||||||
common_name = '.'.join(name.split('.')[:-1]) + '.' + name.split('.')[-1][6:]
|
|
||||||
heat_device = rooms.getobjbyname(common_name + '_valve')
|
|
||||||
setattr(self, common_name.replace('.', '_'), testcase_heating(obj, heat_device))
|
|
||||||
# synchronisation
|
|
||||||
self.gfw_dirk_cd_player_amplifier_sync = testcase_synchronisation(
|
|
||||||
rooms.gfw.dirk.cd_player, None, None,
|
|
||||||
rooms.gfw.dirk.amplifier)
|
|
||||||
self.gfw_floor_main_light_sync = testcase_synchronisation(
|
|
||||||
rooms.gfw.floor.main_light, rooms.gfw.floor.videv_main_light, rooms.gfw.floor.videv_main_light,
|
|
||||||
rooms.gfw.floor.main_light_zigbee_1, rooms.gfw.floor.main_light_zigbee_2
|
|
||||||
)
|
|
||||||
self.ffe_diningroom_main_light_floor_lamp_sync = testcase_synchronisation(
|
|
||||||
rooms.ffe.diningroom.main_light, None, None,
|
|
||||||
rooms.ffe.diningroom.floor_lamp)
|
|
||||||
self.ffe_livingroom_main_light_floor_lamp_sync = testcase_synchronisation(
|
|
||||||
rooms.ffe.livingroom.main_light, rooms.ffe.livingroom.videv_floor_lamp, rooms.ffe.livingroom.videv_floor_lamp,
|
|
||||||
*[getattr(rooms.ffe.livingroom, "floor_lamp_zigbee_%d" % i) for i in range(1, 7)]
|
|
||||||
)
|
|
||||||
# add test collection
|
|
||||||
self.all = test_collection(self)
|
|
||||||
|
|
||||||
def getmembers(self, prefix=''):
|
|
||||||
rv = []
|
|
||||||
for name, obj in inspect.getmembers(self):
|
|
||||||
if prefix:
|
|
||||||
full_name = prefix + '.' + name
|
|
||||||
else:
|
|
||||||
full_name = name
|
|
||||||
if not name.startswith('_'):
|
|
||||||
try:
|
|
||||||
if obj.__class__.__bases__[0].__name__ == "testcase" or obj.__class__.__name__ == "test_collection":
|
|
||||||
rv.append(full_name)
|
|
||||||
else:
|
|
||||||
rv.extend(obj.getmembers(full_name))
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
return rv
|
|
||||||
|
|
||||||
def getobjbyname(self, name):
|
|
||||||
if name.startswith("test."):
|
|
||||||
name = name[5:]
|
|
||||||
obj = self
|
|
||||||
for subname in name.split('.'):
|
|
||||||
obj = getattr(obj, subname)
|
|
||||||
return obj
|
|
||||||
|
|
||||||
def command(self, full_command):
|
|
||||||
try:
|
|
||||||
parameter = " " + full_command.split(' ')[1]
|
|
||||||
except IndexError:
|
|
||||||
parameter = ""
|
|
||||||
command = full_command.split(' ')[0].split('.')[-1] + parameter
|
|
||||||
device_name = '.'.join(full_command.split(' ')[0].split('.')[:-1])
|
|
||||||
self.getobjbyname(device_name).command(command)
|
|
||||||
|
|
||||||
|
|
||||||
class test_result_base(object):
|
|
||||||
def __init__(self):
|
|
||||||
self.__init_test_counters__()
|
|
||||||
|
|
||||||
def __init_test_counters__(self):
|
|
||||||
self.test_counter = 0
|
|
||||||
self.success_tests = 0
|
|
||||||
self.failed_tests = 0
|
|
||||||
|
|
||||||
def statistic(self):
|
|
||||||
return (self.test_counter, self.success_tests, self.failed_tests)
|
|
||||||
|
|
||||||
def print_statistic(self):
|
|
||||||
color = COLOR_SUCCESS if self.test_counter == self.success_tests else COLOR_FAIL
|
|
||||||
print(color + "*** SUCCESS: (%4d/%4d) FAIL: (%4d/%4d) ***\n" % (self.success_tests,
|
|
||||||
self.test_counter, self.failed_tests, self.test_counter) + colored.attr("reset"))
|
|
||||||
|
|
||||||
|
|
||||||
class test_collection(test_result_base):
|
|
||||||
def __init__(self, test_instance):
|
def __init__(self, test_instance):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.test_instance = test_instance
|
self.test_instance = test_instance
|
||||||
|
|
||||||
def capabilities(self):
|
def capabilities(self):
|
||||||
return [TEST_FULL, TEST_SMOKE]
|
return ['full', 'smoke']
|
||||||
|
|
||||||
def command(self, command):
|
def command(self, command):
|
||||||
self.__init_test_counters__()
|
|
||||||
for member in self.test_instance.getmembers():
|
for member in self.test_instance.getmembers():
|
||||||
obj = self.test_instance.getobjbyname(member)
|
obj = self.test_instance.getobjbyname(member)
|
||||||
if id(obj) != id(self):
|
if id(obj) != id(self):
|
||||||
obj.test_all(command)
|
obj.test_all(report.TCEL_FULL if command == 'full' else report.TCEL_SMOKE)
|
||||||
num, suc, fail = obj.statistic()
|
|
||||||
self.test_counter += num
|
|
||||||
self.success_tests += suc
|
|
||||||
self.failed_tests += fail
|
|
||||||
self.print_statistic()
|
|
||||||
|
|
||||||
|
|
||||||
class testcase(test_result_base):
|
class testcase(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.__test_list__ = []
|
self.__test_list__ = []
|
||||||
@ -142,255 +31,13 @@ class testcase(test_result_base):
|
|||||||
self.__test_list__.sort()
|
self.__test_list__.sort()
|
||||||
return self.__test_list__
|
return self.__test_list__
|
||||||
|
|
||||||
def test_all(self, test=TEST_FULL):
|
def test_all(self, tcel=report.TCEL_FULL):
|
||||||
test_counter = 0
|
|
||||||
success_tests = 0
|
|
||||||
failed_tests = 0
|
|
||||||
for tc_name in self.capabilities():
|
for tc_name in self.capabilities():
|
||||||
if tc_name != "test_all":
|
if tc_name != "test_all":
|
||||||
self.command(tc_name, test)
|
self.command(tc_name, tcel)
|
||||||
test_counter += self.test_counter
|
|
||||||
success_tests += self.success_tests
|
|
||||||
failed_tests += self.failed_tests
|
|
||||||
self.test_counter = test_counter
|
|
||||||
self.success_tests = success_tests
|
|
||||||
self.failed_tests = failed_tests
|
|
||||||
|
|
||||||
def command(self, command, test=TEST_FULL):
|
def command(self, command, tcel=report.TCEL_FULL):
|
||||||
self.__init_test_counters__()
|
simulation.devices.OUTPUT_ACTIVE = False
|
||||||
tc = getattr(self, command)
|
tc = getattr(self, command)
|
||||||
self.__init_test_counters__()
|
tc(tcel)
|
||||||
tc(test)
|
simulation.devices.OUTPUT_ACTIVE = True
|
||||||
self.print_statistic()
|
|
||||||
|
|
||||||
def heading(self, desciption):
|
|
||||||
print(desciption)
|
|
||||||
|
|
||||||
def sub_heading(self, desciption):
|
|
||||||
print(2 * " " + desciption)
|
|
||||||
|
|
||||||
def result(self, desciption, success):
|
|
||||||
self.test_counter += 1
|
|
||||||
if success:
|
|
||||||
self.success_tests += 1
|
|
||||||
else:
|
|
||||||
self.failed_tests += 1
|
|
||||||
print(4 * " " + ("SUCCESS - " if success else "FAIL - ") + desciption)
|
|
||||||
|
|
||||||
|
|
||||||
class testcase_light(testcase):
|
|
||||||
def __init__(self, videv, sw_device, li_device):
|
|
||||||
self.videv = videv
|
|
||||||
self.sw_device = sw_device
|
|
||||||
self.li_device = li_device
|
|
||||||
self.__test_list__ = []
|
|
||||||
if self.videv.enable_state:
|
|
||||||
self.__test_list__.append('test_power_on_off')
|
|
||||||
if self.videv.enable_brightness:
|
|
||||||
self.__test_list__.append('test_brightness')
|
|
||||||
if self.videv.enable_color_temp:
|
|
||||||
self.__test_list__.append('test_color_temp')
|
|
||||||
|
|
||||||
def test_power_on_off(self, test=TEST_FULL):
|
|
||||||
self.heading("Power On/ Off test (%s)" % self.videv.topic)
|
|
||||||
#
|
|
||||||
sw_state = self.sw_device.get(self.sw_device.KEY_OUTPUT_0)
|
|
||||||
#
|
|
||||||
for i in range(0, 2):
|
|
||||||
self.sub_heading("State change of switching device")
|
|
||||||
#
|
|
||||||
self.sw_device.set(self.sw_device.KEY_OUTPUT_0, not self.sw_device.get(self.sw_device.KEY_OUTPUT_0))
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
self.result("Virtual device state after Switch on by switching device", sw_state != self.videv.get(self.videv.KEY_OUTPUT_0))
|
|
||||||
self.result("Switching device state after Switch on by switching device",
|
|
||||||
sw_state != self.sw_device.get(self.sw_device.KEY_OUTPUT_0))
|
|
||||||
|
|
||||||
self.sub_heading("State change of virtual device")
|
|
||||||
#
|
|
||||||
self.videv.set(self.videv.KEY_OUTPUT_0, not self.videv.get(self.videv.KEY_OUTPUT_0))
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
self.result("Virtual device state after Switch off by virtual device", sw_state == self.videv.get(self.videv.KEY_OUTPUT_0))
|
|
||||||
self.result("Switching device state after Switch on by switching device",
|
|
||||||
sw_state == self.sw_device.get(self.sw_device.KEY_OUTPUT_0))
|
|
||||||
|
|
||||||
def test_brightness(self, test=TEST_FULL):
|
|
||||||
self.heading("Brightness test (%s)" % self.videv.topic)
|
|
||||||
#
|
|
||||||
br_state = self.li_device.get(self.li_device.KEY_BRIGHTNESS)
|
|
||||||
delta = -15 if br_state > 50 else 15
|
|
||||||
|
|
||||||
self.sw_device.set(self.sw_device.KEY_OUTPUT_0, True)
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
|
|
||||||
for i in range(0, 2):
|
|
||||||
self.sub_heading("Brightness change by light device")
|
|
||||||
#
|
|
||||||
self.li_device.set(self.li_device.KEY_BRIGHTNESS, br_state + delta)
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
self.result("Virtual device state after setting brightness by light device",
|
|
||||||
br_state + delta == self.videv.get(self.videv.KEY_BRIGHTNESS))
|
|
||||||
self.result("Light device state after setting brightness by light device", br_state +
|
|
||||||
delta == self.li_device.get(self.li_device.KEY_BRIGHTNESS))
|
|
||||||
|
|
||||||
self.sub_heading("Brightness change by virtual device")
|
|
||||||
#
|
|
||||||
self.videv.set(self.videv.KEY_BRIGHTNESS, br_state)
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
self.result("Virtual device state after setting brightness by light device", br_state == self.videv.get(self.videv.KEY_BRIGHTNESS))
|
|
||||||
self.result("Light device state after setting brightness by light device",
|
|
||||||
br_state == self.li_device.get(self.li_device.KEY_BRIGHTNESS))
|
|
||||||
|
|
||||||
self.sw_device.set(self.sw_device.KEY_OUTPUT_0, False)
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
|
|
||||||
def test_color_temp(self, test=TEST_FULL):
|
|
||||||
self.heading("Color temperature test (%s)" % self.videv.topic)
|
|
||||||
#
|
|
||||||
ct_state = self.li_device.get(self.li_device.KEY_COLOR_TEMP)
|
|
||||||
delta = -3 if ct_state > 5 else 3
|
|
||||||
|
|
||||||
self.sw_device.set(self.sw_device.KEY_OUTPUT_0, True)
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
|
|
||||||
for i in range(0, 2):
|
|
||||||
self.sub_heading("Color temperature change by light device")
|
|
||||||
#
|
|
||||||
self.li_device.set(self.li_device.KEY_COLOR_TEMP, ct_state + delta)
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
self.result("Virtual device state after setting color temperature by light device",
|
|
||||||
ct_state + delta == self.videv.get(self.videv.KEY_COLOR_TEMP))
|
|
||||||
self.result("Light device state after setting color temperature by light device", ct_state +
|
|
||||||
delta == self.li_device.get(self.li_device.KEY_COLOR_TEMP))
|
|
||||||
|
|
||||||
self.sub_heading("Color temperature change by virtual device")
|
|
||||||
#
|
|
||||||
self.videv.set(self.videv.KEY_COLOR_TEMP, ct_state)
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
self.result("Virtual device state after setting color temperature by light device",
|
|
||||||
ct_state == self.videv.get(self.videv.KEY_COLOR_TEMP))
|
|
||||||
self.result("Light device state after setting color temperature by light device",
|
|
||||||
ct_state == self.li_device.get(self.li_device.KEY_COLOR_TEMP))
|
|
||||||
|
|
||||||
self.sw_device.set(self.sw_device.KEY_OUTPUT_0, False)
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
|
|
||||||
|
|
||||||
class testcase_synchronisation(testcase):
|
|
||||||
def __init__(self, sw_master, br_master, ct_master, *follower):
|
|
||||||
super().__init__()
|
|
||||||
self.sw_master = sw_master
|
|
||||||
self.br_master = br_master
|
|
||||||
self.ct_master = ct_master
|
|
||||||
self.follower = follower
|
|
||||||
self.__test_list__ = []
|
|
||||||
if sw_master is not None:
|
|
||||||
self.__test_list__.append('test_power_on_off_sync')
|
|
||||||
if br_master is not None:
|
|
||||||
self.__test_list__.append('test_brightness_sync')
|
|
||||||
|
|
||||||
def test_power_on_off_sync(self, test=TEST_FULL):
|
|
||||||
self.heading("Power On/ Off sychronisation test")
|
|
||||||
#
|
|
||||||
# set sw_master to slave state as precondition
|
|
||||||
f_state = self.follower[0].get(self.follower[0].KEY_OUTPUT_0)
|
|
||||||
self.sw_master.set(self.sw_master.KEY_OUTPUT_0, f_state)
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
for i in range(0, 2):
|
|
||||||
self.sub_heading("State change of sw_master device")
|
|
||||||
#
|
|
||||||
self.sw_master.set(self.sw_master.KEY_OUTPUT_0, not f_state)
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
f_state = not f_state
|
|
||||||
for fo in self.follower:
|
|
||||||
self.result("Follower device state after switching (%s)" % fo.topic,
|
|
||||||
f_state == fo.get(fo.KEY_OUTPUT_0))
|
|
||||||
|
|
||||||
def test_brightness_sync(self, test=TEST_FULL):
|
|
||||||
self.heading("Power On/ Off sychronisation test")
|
|
||||||
#
|
|
||||||
# set precondition
|
|
||||||
sw_state = self.sw_master.get(self.sw_master.KEY_OUTPUT_0)
|
|
||||||
self.sw_master.set(self.sw_master.KEY_OUTPUT_0, True)
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
|
|
||||||
target = self.follower[0].get(self.follower[0].KEY_BRIGHTNESS)
|
|
||||||
delta = 15 if target < 50 else -15
|
|
||||||
for i in range(0, 2):
|
|
||||||
target = target + delta
|
|
||||||
self.sub_heading("State change of br_master device")
|
|
||||||
#
|
|
||||||
self.br_master.set(self.br_master.KEY_BRIGHTNESS, target)
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
for fo in self.follower:
|
|
||||||
self.result("Follower device brightness after change (%s)" % fo.topic,
|
|
||||||
target == fo.get(fo.KEY_BRIGHTNESS))
|
|
||||||
delta = -delta
|
|
||||||
|
|
||||||
# reset changes of precondition
|
|
||||||
self.sw_master.set(self.sw_master.KEY_OUTPUT_0, sw_state)
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
|
|
||||||
|
|
||||||
class testcase_heating(testcase):
|
|
||||||
def __init__(self, videv, valve):
|
|
||||||
self.__videv__ = videv
|
|
||||||
self.__valve__ = valve
|
|
||||||
self.__default_temperature__ = config.DEFAULT_TEMPERATURE.get(self.__valve__.topic)
|
|
||||||
self.__test_list__ = ["test_user_temperature_setpoint", "test_default_temperature", ]
|
|
||||||
|
|
||||||
def test_user_temperature_setpoint(self, test=TEST_FULL):
|
|
||||||
self.heading("User temperature setpoint test (%s)" % self.__videv__.topic)
|
|
||||||
#
|
|
||||||
mtemp = round(self.__valve__.TEMP_RANGE[0] + (self.__valve__.TEMP_RANGE[1] - self.__valve__.TEMP_RANGE[0]) / 2, 1)
|
|
||||||
setp = self.__valve__.get(self.__valve__.KEY_TEMPERATURE_SETPOINT)
|
|
||||||
delta = 5 if setp < mtemp else -5
|
|
||||||
|
|
||||||
for i in range(0, 2):
|
|
||||||
self.sub_heading("Setpoint change by valve device")
|
|
||||||
#
|
|
||||||
self.__valve__.set(self.__valve__.KEY_TEMPERATURE_SETPOINT, setp + delta)
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
self.result("Virtual device valve temperature after setting temperature by valve device",
|
|
||||||
setp + delta == self.__videv__.get(self.__videv__.KEY_VALVE_TEMPERATURE_SETPOINT))
|
|
||||||
self.result("Virtual device user temperature after setting temperature by valve device",
|
|
||||||
setp + delta == self.__videv__.get(self.__videv__.KEY_USER_TEMPERATURE_SETPOINT))
|
|
||||||
|
|
||||||
self.sub_heading("Setpoint change by videv device")
|
|
||||||
#
|
|
||||||
self.__videv__.set(self.__videv__.KEY_USER_TEMPERATURE_SETPOINT, setp)
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
self.result("Valve device temperature setpoint after setting temperature by videv device",
|
|
||||||
setp == self.__valve__.get(self.__valve__.KEY_TEMPERATURE_SETPOINT))
|
|
||||||
self.result("Virtual device valve temperature after setting temperature by videv device",
|
|
||||||
setp == self.__videv__.get(self.__videv__.KEY_VALVE_TEMPERATURE_SETPOINT))
|
|
||||||
|
|
||||||
def test_default_temperature(self, test=TEST_FULL):
|
|
||||||
self.heading("Default temperature setpoint test (%s)" % self.__videv__.topic)
|
|
||||||
#
|
|
||||||
dtemp = config.DEFAULT_TEMPERATURE.get(self.__valve__.topic)
|
|
||||||
mtemp = round(self.__valve__.TEMP_RANGE[0] + (self.__valve__.TEMP_RANGE[1] - self.__valve__.TEMP_RANGE[0]) / 2, 1)
|
|
||||||
ptemp = dtemp + (5 if dtemp < mtemp else -5)
|
|
||||||
|
|
||||||
self.sub_heading("Setting setpoint to a value unequal default as precondition")
|
|
||||||
self.__valve__.set(self.__valve__.KEY_TEMPERATURE_SETPOINT, ptemp)
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
self.result("Valve device temperature setpoint after setting precondition temperature",
|
|
||||||
ptemp == self.__valve__.get(self.__valve__.KEY_TEMPERATURE_SETPOINT))
|
|
||||||
|
|
||||||
self.sub_heading("Triggering default temperature by videv device")
|
|
||||||
self.__videv__.set(self.__videv__.KEY_SET_DEFAULT_TEMPERATURE, None)
|
|
||||||
time.sleep(DT_TOGGLE)
|
|
||||||
self.result("Valve device temperature setpoint after setting default temperature",
|
|
||||||
dtemp == self.__valve__.get(self.__valve__.KEY_TEMPERATURE_SETPOINT))
|
|
||||||
|
|
||||||
def test_summer_mode(self, test=TEST_FULL):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def test_away_mode(self, test=TEST_FULL):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def test_boost_mode(self, test=TEST_FULL):
|
|
||||||
pass
|
|
||||||
if test == TEST_FULL:
|
|
||||||
# test boost timer
|
|
||||||
pass
|
|
||||||
|
139
tests/all.py
Normal file
139
tests/all.py
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
import distro
|
||||||
|
import getpass
|
||||||
|
import inspect
|
||||||
|
import jinja2
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import report
|
||||||
|
from tests import test_collection
|
||||||
|
from tests.heating import testcase_heating
|
||||||
|
from tests.light import testcase_light
|
||||||
|
from tests.synchronisation import testcase_synchronisation
|
||||||
|
from unittest import jsonlog
|
||||||
|
|
||||||
|
try:
|
||||||
|
from config import APP_NAME as ROOT_LOGGER_NAME
|
||||||
|
except ImportError:
|
||||||
|
ROOT_LOGGER_NAME = 'root'
|
||||||
|
|
||||||
|
|
||||||
|
class test_smarthome(object):
|
||||||
|
def __init__(self, rooms):
|
||||||
|
self.__init__tcl__()
|
||||||
|
# add testcases for switching devices
|
||||||
|
for name in rooms.getmembers():
|
||||||
|
obj = rooms.getobjbyname(name)
|
||||||
|
if obj.__class__.__name__ == "videv_light":
|
||||||
|
common_name = '.'.join(name.split('.')[:-1]) + '.' + name.split('.')[-1][6:]
|
||||||
|
try:
|
||||||
|
li_device = rooms.getobjbyname(common_name + '_zigbee') if obj.enable_brightness or obj.enable_color_temp else None
|
||||||
|
except AttributeError:
|
||||||
|
li_device = rooms.getobjbyname(common_name + '_zigbee_1') if obj.enable_brightness or obj.enable_color_temp else None
|
||||||
|
try:
|
||||||
|
sw_device = rooms.getobjbyname(common_name) if obj.enable_state else None
|
||||||
|
except AttributeError:
|
||||||
|
# must be a device without switching device
|
||||||
|
sw_device = li_device
|
||||||
|
setattr(self, common_name.replace('.', '_'), testcase_light(self.tcl, obj, sw_device, li_device))
|
||||||
|
# add testcases for heating devices
|
||||||
|
for name in rooms.getmembers():
|
||||||
|
obj = rooms.getobjbyname(name)
|
||||||
|
if obj.__class__.__name__ == "videv_heating":
|
||||||
|
common_name = '.'.join(name.split('.')[:-1]) + '.' + name.split('.')[-1][6:]
|
||||||
|
heat_device = rooms.getobjbyname(common_name + '_valve')
|
||||||
|
setattr(self, common_name.replace('.', '_'), testcase_heating(self.tcl, obj, heat_device))
|
||||||
|
# synchronisation
|
||||||
|
# gfw.dirk.amplifier with cd_player
|
||||||
|
self.gfw_dirk_cd_player_amplifier_sync = testcase_synchronisation(
|
||||||
|
self.tcl,
|
||||||
|
rooms.gfw.dirk.cd_player, None, None,
|
||||||
|
rooms.gfw.dirk.amplifier)
|
||||||
|
# gfw.floor.main_light_2 with gfw.floor.main_light_1
|
||||||
|
self.gfw_floor_main_light_sync = testcase_synchronisation(
|
||||||
|
self.tcl,
|
||||||
|
rooms.gfw.floor.main_light, rooms.gfw.floor.videv_main_light, rooms.gfw.floor.videv_main_light,
|
||||||
|
rooms.gfw.floor.main_light_zigbee_1, rooms.gfw.floor.main_light_zigbee_2
|
||||||
|
)
|
||||||
|
# ffe.diningroom.floorlamp with ffe.dinigroom.main_light
|
||||||
|
self.ffe_diningroom_main_light_floor_lamp_sync = testcase_synchronisation(
|
||||||
|
self.tcl,
|
||||||
|
rooms.ffe.diningroom.main_light, None, None,
|
||||||
|
rooms.ffe.diningroom.floor_lamp)
|
||||||
|
# ffe.livingroom.floorlamp_[1-6] with ffe.livingroom.main_light
|
||||||
|
self.ffe_livingroom_main_light_floor_lamp_sync = testcase_synchronisation(
|
||||||
|
self.tcl,
|
||||||
|
rooms.ffe.livingroom.main_light, rooms.ffe.livingroom.videv_floor_lamp, rooms.ffe.livingroom.videv_floor_lamp,
|
||||||
|
*[getattr(rooms.ffe.livingroom, "floor_lamp_zigbee_%d" % i) for i in range(1, 7)]
|
||||||
|
)
|
||||||
|
# add test collection
|
||||||
|
self.all = test_collection(self)
|
||||||
|
|
||||||
|
def __init__tcl__(self):
|
||||||
|
system_info = {}
|
||||||
|
system_info[jsonlog.SYSI_ARCHITECTURE] = platform.architecture()[0]
|
||||||
|
system_info[jsonlog.SYSI_MACHINE] = platform.machine()
|
||||||
|
system_info[jsonlog.SYSI_HOSTNAME] = platform.node()
|
||||||
|
system_info[jsonlog.SYSI_DISTRIBUTION] = distro.name() + " " + distro.version() + " (" + distro.codename() + ")"
|
||||||
|
system_info[jsonlog.SYSI_SYSTEM] = platform.system()
|
||||||
|
system_info[jsonlog.SYSI_KERNEL] = platform.release() + ' (%s)' % platform.version()
|
||||||
|
system_info[jsonlog.SYSI_USERNAME] = getpass.getuser()
|
||||||
|
system_info[jsonlog.SYSI_PATH] = os.path.abspath(os.path.basename(__file__))
|
||||||
|
|
||||||
|
self.tcl = report.testSession(['__unittest__', 'unittest', ROOT_LOGGER_NAME])
|
||||||
|
self.tcl[jsonlog.MAIN_KEY_SYSTEM_INFO] = system_info
|
||||||
|
|
||||||
|
def __eval_tcl__(self):
|
||||||
|
path = os.path.abspath(os.path.join(os.path.basename(__file__), '..'))
|
||||||
|
|
||||||
|
with open(os.path.join(path, "testresults", "testrun.json"), "w") as fh:
|
||||||
|
fh.write(json.dumps(self.tcl, indent=4))
|
||||||
|
|
||||||
|
template_path = os.path.join(path, 'templates')
|
||||||
|
template_filename = 'unittest.tex'
|
||||||
|
jenv = jinja2.Environment(loader=jinja2.FileSystemLoader(template_path))
|
||||||
|
template = jenv.get_template(template_filename)
|
||||||
|
with open(os.path.join(path, "testresults", "testrun.tex"), "w") as fh:
|
||||||
|
fh.write(template.render(data=self.tcl, details=False))
|
||||||
|
with open(os.path.join(path, "testresults", "testrun_full.tex"), "w") as fh:
|
||||||
|
fh.write(template.render(data=self.tcl, details=True))
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
try:
|
||||||
|
self.__eval_tcl__()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
def getmembers(self, prefix=''):
|
||||||
|
rv = []
|
||||||
|
for name, obj in inspect.getmembers(self):
|
||||||
|
if prefix:
|
||||||
|
full_name = prefix + '.' + name
|
||||||
|
else:
|
||||||
|
full_name = name
|
||||||
|
if not name.startswith('_'):
|
||||||
|
try:
|
||||||
|
if obj.__class__.__bases__[0].__name__ == "testcase" or obj.__class__.__name__ == "test_collection":
|
||||||
|
rv.append(full_name)
|
||||||
|
else:
|
||||||
|
rv.extend(obj.getmembers(full_name))
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
return rv
|
||||||
|
|
||||||
|
def getobjbyname(self, name):
|
||||||
|
if name.startswith("test."):
|
||||||
|
name = name[5:]
|
||||||
|
obj = self
|
||||||
|
for subname in name.split('.'):
|
||||||
|
obj = getattr(obj, subname)
|
||||||
|
return obj
|
||||||
|
|
||||||
|
def command(self, full_command):
|
||||||
|
try:
|
||||||
|
parameter = " " + full_command.split(' ')[1]
|
||||||
|
except IndexError:
|
||||||
|
parameter = ""
|
||||||
|
command = full_command.split(' ')[0].split('.')[-1] + parameter
|
||||||
|
device_name = '.'.join(full_command.split(' ')[0].split('.')[:-1])
|
||||||
|
self.getobjbyname(device_name).command(command)
|
129
tests/heating.py
Normal file
129
tests/heating.py
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
import config
|
||||||
|
import report
|
||||||
|
from tests import testcase, DT_TOGGLE
|
||||||
|
import time
|
||||||
|
from unittest.test import equivalency_chk, greater_chk
|
||||||
|
|
||||||
|
|
||||||
|
class testcase_heating(testcase):
|
||||||
|
def __init__(self, tcl, videv, valve):
|
||||||
|
self.tcl = tcl
|
||||||
|
self.__videv__ = videv
|
||||||
|
self.__valve__ = valve
|
||||||
|
self.__default_temperature__ = config.DEFAULT_TEMPERATURE.get(self.__valve__.topic)
|
||||||
|
self.__test_list__ = ["test_user_temperature_setpoint", "test_default_temperature", "test_summer_mode", "test_away_mode", "test_boost_mode"]
|
||||||
|
|
||||||
|
def test_user_temperature_setpoint(self, tcel=report.TCEL_FULL):
|
||||||
|
self.tcl.testCase("User temperature setpoint test for device and virtual device: %s" %
|
||||||
|
self.__valve__.topic, tcel, self.__test_user_temperature_setpoint__, tcel)
|
||||||
|
|
||||||
|
def __test_user_temperature_setpoint__(self, tLogger, tcel):
|
||||||
|
mtemp = round(self.__valve__.TEMP_RANGE[0] + (self.__valve__.TEMP_RANGE[1] - self.__valve__.TEMP_RANGE[0]) / 2, 1)
|
||||||
|
setp = self.__valve__.get(self.__valve__.KEY_TEMPERATURE_SETPOINT)
|
||||||
|
delta = 5 if setp < mtemp else -5
|
||||||
|
|
||||||
|
for i in range(0, 2):
|
||||||
|
self.__valve__.set(self.__valve__.KEY_TEMPERATURE_SETPOINT, setp + delta)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Changing valve temperature setpoint to '%.1f'", setp + delta)
|
||||||
|
equivalency_chk(self.__videv__.get(self.__videv__.KEY_VALVE_TEMPERATURE_SETPOINT),
|
||||||
|
setp + delta, tLogger, "Virtual device valve temperature")
|
||||||
|
equivalency_chk(self.__videv__.get(self.__videv__.KEY_USER_TEMPERATURE_SETPOINT),
|
||||||
|
setp + delta, tLogger, "Virtual device user temperature")
|
||||||
|
#
|
||||||
|
self.__videv__.set(self.__videv__.KEY_USER_TEMPERATURE_SETPOINT, setp)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Changing videv user temperature setpoint to '%.1f'", setp)
|
||||||
|
equivalency_chk(self.__valve__.get(self.__valve__.KEY_TEMPERATURE_SETPOINT), setp, tLogger, "Valve device temperature setpoint")
|
||||||
|
equivalency_chk(self.__videv__.get(self.__videv__.KEY_VALVE_TEMPERATURE_SETPOINT), setp, tLogger, "Virtual device valve temperature")
|
||||||
|
|
||||||
|
def test_default_temperature(self, tcel=report.TCEL_FULL):
|
||||||
|
self.tcl.testCase("Default temperature test for device and virtual device: %s" %
|
||||||
|
self.__valve__.topic, tcel, self.__test_default_temperature__, tcel)
|
||||||
|
|
||||||
|
def __test_default_temperature__(self, tLogger, tcel):
|
||||||
|
dtemp = config.DEFAULT_TEMPERATURE.get(self.__valve__.topic)
|
||||||
|
mtemp = round(self.__valve__.TEMP_RANGE[0] + (self.__valve__.TEMP_RANGE[1] - self.__valve__.TEMP_RANGE[0]) / 2, 1)
|
||||||
|
ptemp = dtemp + (5 if dtemp < mtemp else -5)
|
||||||
|
|
||||||
|
self.__valve__.set(self.__valve__.KEY_TEMPERATURE_SETPOINT, ptemp)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Setting preconditions (Valve setpoint to %.1f)", ptemp)
|
||||||
|
|
||||||
|
equivalency_chk(self.__valve__.get(self.__valve__.KEY_TEMPERATURE_SETPOINT) != dtemp,
|
||||||
|
True, tLogger, "Valve temperature setpoint (is not default temperature)")
|
||||||
|
self.__videv__.set(self.__videv__.KEY_SET_DEFAULT_TEMPERATURE, None)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Triggering set to default temperature (%.1f)", dtemp)
|
||||||
|
equivalency_chk(self.__valve__.get(self.__valve__.KEY_TEMPERATURE_SETPOINT), dtemp, tLogger, "Valve temperature setpoint")
|
||||||
|
|
||||||
|
def test_summer_mode(self, tcel=report.TCEL_FULL):
|
||||||
|
self.tcl.testCase("Summer mode test: %s" % self.__valve__.topic, tcel, self.__test_summer_mode__, tcel)
|
||||||
|
|
||||||
|
def __test_summer_mode__(self, tLogger, tcel):
|
||||||
|
self.__videv__.set(self.__videv__.KEY_SET_DEFAULT_TEMPERATURE, None)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Setting preconditions (Default setpoint)")
|
||||||
|
|
||||||
|
vtemp = self.__valve__.get(self.__valve__.KEY_TEMPERATURE_SETPOINT)
|
||||||
|
|
||||||
|
equivalency_chk(self.__videv__.get(self.__videv__.KEY_SUMMER_MODE), False, tLogger, "Summer mode")
|
||||||
|
self.__videv__.set(self.__videv__.KEY_SUMMER_MODE, True)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Activating summer mode")
|
||||||
|
equivalency_chk(self.__videv__.get(self.__videv__.KEY_SUMMER_MODE), True, tLogger, "Summer mode")
|
||||||
|
equivalency_chk(self.__valve__.get(self.__valve__.KEY_TEMPERATURE_SETPOINT), 5, tLogger, "Temperature setpoint")
|
||||||
|
|
||||||
|
self.__videv__.set(self.__videv__.KEY_SUMMER_MODE, False)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Deactivating summer mode")
|
||||||
|
equivalency_chk(self.__videv__.get(self.__videv__.KEY_SUMMER_MODE), False, tLogger, "Summer mode")
|
||||||
|
equivalency_chk(self.__valve__.get(self.__valve__.KEY_TEMPERATURE_SETPOINT), vtemp, tLogger, "Temperature setpoint")
|
||||||
|
|
||||||
|
def test_away_mode(self, tcel=report.TCEL_FULL):
|
||||||
|
self.tcl.testCase("Away mode test: %s" % self.__valve__.topic, tcel, self.__test_away_mode__, tcel)
|
||||||
|
|
||||||
|
def __test_away_mode__(self, tLogger, tcel):
|
||||||
|
self.__videv__.set(self.__videv__.KEY_SET_DEFAULT_TEMPERATURE, None)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Setting preconditions (Default setpoint)")
|
||||||
|
|
||||||
|
vtemp = self.__valve__.get(self.__valve__.KEY_TEMPERATURE_SETPOINT)
|
||||||
|
|
||||||
|
equivalency_chk(self.__videv__.get(self.__videv__.KEY_AWAY_MODE), False, tLogger, "Away mode")
|
||||||
|
self.__videv__.set(self.__videv__.KEY_AWAY_MODE, True)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Activating away mode")
|
||||||
|
equivalency_chk(self.__videv__.get(self.__videv__.KEY_AWAY_MODE), True, tLogger, "Away mode")
|
||||||
|
equivalency_chk(self.__valve__.get(self.__valve__.KEY_TEMPERATURE_SETPOINT), vtemp - 5, tLogger, "Temperature setpoint")
|
||||||
|
|
||||||
|
self.__videv__.set(self.__videv__.KEY_AWAY_MODE, False)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Deactivating away mode")
|
||||||
|
equivalency_chk(self.__videv__.get(self.__videv__.KEY_AWAY_MODE), False, tLogger, "Away mode")
|
||||||
|
equivalency_chk(self.__valve__.get(self.__valve__.KEY_TEMPERATURE_SETPOINT), vtemp, tLogger, "Temperature setpoint")
|
||||||
|
|
||||||
|
def test_boost_mode(self, tcel=report.TCEL_FULL):
|
||||||
|
self.tcl.testCase("Boost mode test: %s" % self.__valve__.topic, tcel, self.__test_boost_mode__, tcel)
|
||||||
|
|
||||||
|
def __test_boost_mode__(self, tLogger, tcel):
|
||||||
|
self.__videv__.set(self.__videv__.KEY_SET_DEFAULT_TEMPERATURE, None)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Setting preconditions (Default setpoint)")
|
||||||
|
|
||||||
|
vtemp = self.__valve__.get(self.__valve__.KEY_TEMPERATURE_SETPOINT)
|
||||||
|
|
||||||
|
equivalency_chk(self.__videv__.get(self.__videv__.KEY_BOOST_TIMER), 0, tLogger, "Boost timer")
|
||||||
|
self.__videv__.set(self.__videv__.KEY_START_BOOST, None)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Activating boost mode")
|
||||||
|
greater_chk(self.__videv__.get(self.__videv__.KEY_BOOST_TIMER), 0, tLogger, "Boost timer")
|
||||||
|
|
||||||
|
self.__videv__.set(self.__videv__.KEY_SET_DEFAULT_TEMPERATURE, None)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Setting postconditions (Default setpoint)")
|
||||||
|
equivalency_chk(self.__videv__.get(self.__videv__.KEY_BOOST_TIMER), 0, tLogger, "Boost timer")
|
||||||
|
|
||||||
|
if tcel == report.TCEL_FULL:
|
||||||
|
# test boost timer
|
||||||
|
pass
|
92
tests/light.py
Normal file
92
tests/light.py
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
import report
|
||||||
|
from tests import testcase, DT_TOGGLE
|
||||||
|
import time
|
||||||
|
from unittest.test import equivalency_chk
|
||||||
|
|
||||||
|
|
||||||
|
class testcase_light(testcase):
|
||||||
|
def __init__(self, tcl, videv, sw_device, li_device):
|
||||||
|
self.tcl = tcl
|
||||||
|
self.videv = videv
|
||||||
|
self.sw_device = sw_device
|
||||||
|
self.li_device = li_device
|
||||||
|
self.__test_list__ = []
|
||||||
|
if self.videv.enable_state:
|
||||||
|
self.__test_list__.append('test_power_on_off')
|
||||||
|
if self.videv.enable_brightness:
|
||||||
|
self.__test_list__.append('test_brightness')
|
||||||
|
if self.videv.enable_color_temp:
|
||||||
|
self.__test_list__.append('test_color_temp')
|
||||||
|
|
||||||
|
def test_power_on_off(self, tcel=report.TCEL_FULL):
|
||||||
|
self.tcl.testCase("Power On/ Off test for device and virtual device: %s" % self.sw_device.topic, tcel, self.__test_power_on_off__, tcel)
|
||||||
|
|
||||||
|
def __test_power_on_off__(self, tLogger, tcel):
|
||||||
|
sw_state = self.sw_device.get(self.sw_device.KEY_OUTPUT_0)
|
||||||
|
|
||||||
|
for i in range(0, 2):
|
||||||
|
equivalency_chk(self.videv.get(self.videv.KEY_OUTPUT_0), sw_state, tLogger, "Virtual device state")
|
||||||
|
self.sw_device.set(self.sw_device.KEY_OUTPUT_0, not sw_state)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Changing switching device state to '%s'", not sw_state)
|
||||||
|
equivalency_chk(self.videv.get(self.videv.KEY_OUTPUT_0), not sw_state, tLogger, "Virtual device state")
|
||||||
|
#
|
||||||
|
equivalency_chk(self.sw_device.get(self.sw_device.KEY_OUTPUT_0), not sw_state, tLogger, "Switching device state")
|
||||||
|
self.videv.set(self.videv.KEY_OUTPUT_0, sw_state)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Changing virtual device state to '%s'", sw_state)
|
||||||
|
equivalency_chk(self.sw_device.get(self.sw_device.KEY_OUTPUT_0), sw_state, tLogger, "Switching device state")
|
||||||
|
|
||||||
|
def test_brightness(self, tcel=report.TCEL_FULL):
|
||||||
|
self.tcl.testCase("Brightness test for device and virtual device: %s" % self.li_device.topic, tcel, self.__test_brightness__, tcel)
|
||||||
|
|
||||||
|
def __test_brightness__(self, tLogger, tcel):
|
||||||
|
br_state = self.li_device.get(self.li_device.KEY_BRIGHTNESS)
|
||||||
|
delta = -15 if br_state > 50 else 15
|
||||||
|
self.sw_device.set(self.sw_device.KEY_OUTPUT_0, True)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Setting preconditions (Power on)")
|
||||||
|
|
||||||
|
for i in range(0, 2):
|
||||||
|
equivalency_chk(self.videv.get(self.videv.KEY_BRIGHTNESS), br_state, tLogger, "Virtual device brightness")
|
||||||
|
self.li_device.set(self.li_device.KEY_BRIGHTNESS, br_state + delta)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Changing light device brightness to '%d'", br_state + delta)
|
||||||
|
equivalency_chk(self.videv.get(self.videv.KEY_BRIGHTNESS), br_state + delta, tLogger, "Virtual device brightness")
|
||||||
|
#
|
||||||
|
equivalency_chk(self.li_device.get(self.li_device.KEY_BRIGHTNESS), br_state + delta, tLogger, "Light device brightness")
|
||||||
|
self.videv.set(self.videv.KEY_BRIGHTNESS, br_state)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Changing virtual device brightness to '%d'", br_state)
|
||||||
|
equivalency_chk(self.li_device.get(self.li_device.KEY_BRIGHTNESS), br_state, tLogger, "Light device brightness")
|
||||||
|
#
|
||||||
|
self.sw_device.set(self.sw_device.KEY_OUTPUT_0, False)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Resetting precondition (Power off)")
|
||||||
|
|
||||||
|
def test_color_temp(self, tcel=report.TCEL_FULL):
|
||||||
|
self.tcl.testCase("Color temperature test for device and virtual device: %s" % self.li_device.topic, tcel, self.__test_color_temp__, tcel)
|
||||||
|
|
||||||
|
def __test_color_temp__(self, tLogger, tcel):
|
||||||
|
ct_state = self.li_device.get(self.li_device.KEY_COLOR_TEMP)
|
||||||
|
delta = -3 if ct_state > 5 else 3
|
||||||
|
self.sw_device.set(self.sw_device.KEY_OUTPUT_0, True)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Setting preconditions (Power on)")
|
||||||
|
|
||||||
|
for i in range(0, 2):
|
||||||
|
equivalency_chk(self.videv.get(self.videv.KEY_COLOR_TEMP), ct_state, tLogger, "Virtual device color temperature")
|
||||||
|
self.li_device.set(self.li_device.KEY_COLOR_TEMP, ct_state + delta)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Changing light device color temperature to '%d'", ct_state)
|
||||||
|
equivalency_chk(self.videv.get(self.videv.KEY_COLOR_TEMP), ct_state + delta, tLogger, "Virtual device color temperature")
|
||||||
|
#
|
||||||
|
equivalency_chk(self.li_device.get(self.li_device.KEY_COLOR_TEMP), ct_state + delta, tLogger, "Light device brightness")
|
||||||
|
self.videv.set(self.videv.KEY_COLOR_TEMP, ct_state)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Changing virtual device color temperature to '%d'", ct_state)
|
||||||
|
equivalency_chk(self.li_device.get(self.li_device.KEY_COLOR_TEMP), ct_state, tLogger, "Light device brightness")
|
||||||
|
#
|
||||||
|
self.sw_device.set(self.sw_device.KEY_OUTPUT_0, False)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Resetting precondition (Power off)")
|
90
tests/synchronisation.py
Normal file
90
tests/synchronisation.py
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
import report
|
||||||
|
from tests import testcase, DT_TOGGLE
|
||||||
|
import time
|
||||||
|
from unittest.test import equivalency_chk
|
||||||
|
|
||||||
|
|
||||||
|
class testcase_synchronisation(testcase):
|
||||||
|
def __init__(self, tcl, sw_master, br_master, ct_master, *follower):
|
||||||
|
super().__init__()
|
||||||
|
self.tcl = tcl
|
||||||
|
self.sw_master = sw_master
|
||||||
|
self.br_master = br_master
|
||||||
|
self.ct_master = ct_master
|
||||||
|
self.follower = follower
|
||||||
|
#
|
||||||
|
self.__test_list__ = []
|
||||||
|
if sw_master is not None:
|
||||||
|
self.__test_list__.append('test_power_on_off_sync')
|
||||||
|
if br_master is not None:
|
||||||
|
self.__test_list__.append('test_brightness_sync')
|
||||||
|
if ct_master is not None:
|
||||||
|
self.__test_list__.append('test_color_temp_sync')
|
||||||
|
|
||||||
|
def test_power_on_off_sync(self, tcel=report.TCEL_FULL):
|
||||||
|
self.tcl.testCase("Power On/ Off synchronisation test: %s" % self.sw_master.topic, tcel, self.__test_power_on_off_sync__, tcel)
|
||||||
|
|
||||||
|
def __test_power_on_off_sync__(self, tLogger, tcel):
|
||||||
|
f_state = self.follower[0].get(self.follower[0].KEY_OUTPUT_0)
|
||||||
|
self.sw_master.set(self.sw_master.KEY_OUTPUT_0, f_state)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Setting preconditions for master device '%s'", f_state)
|
||||||
|
|
||||||
|
for i in range(0, 2):
|
||||||
|
f_state = not f_state
|
||||||
|
self.sw_master.set(self.sw_master.KEY_OUTPUT_0, f_state)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Changing master device state to '%s'", f_state)
|
||||||
|
|
||||||
|
for fo in self.follower:
|
||||||
|
equivalency_chk(fo.get(fo.KEY_OUTPUT_0), f_state, tLogger, "Follower device (%s) state" % fo.topic)
|
||||||
|
|
||||||
|
def test_brightness_sync(self, tcel=report.TCEL_FULL):
|
||||||
|
self.tcl.testCase("Brightness synchronisation test: %s" % self.br_master.topic, tcel, self.__test_brightness_sync__, tcel)
|
||||||
|
|
||||||
|
def __test_brightness_sync__(self, tLogger, tcel):
|
||||||
|
sw_state = self.sw_master.get(self.sw_master.KEY_OUTPUT_0)
|
||||||
|
self.sw_master.set(self.sw_master.KEY_OUTPUT_0, True)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Setting preconditions for master device '%s' (Power on)", True)
|
||||||
|
|
||||||
|
target = self.follower[0].get(self.follower[0].KEY_BRIGHTNESS)
|
||||||
|
delta = 15 if target < 50 else -15
|
||||||
|
for i in range(0, 2):
|
||||||
|
target = target + delta
|
||||||
|
self.br_master.set(self.br_master.KEY_BRIGHTNESS, target)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Changing master device brightness to '%d'", target)
|
||||||
|
for fo in self.follower:
|
||||||
|
equivalency_chk(fo.get(fo.KEY_BRIGHTNESS), target, tLogger, "Follower device (%s) brightness" % fo.topic)
|
||||||
|
delta = -delta
|
||||||
|
|
||||||
|
# reset changes of precondition
|
||||||
|
self.sw_master.set(self.sw_master.KEY_OUTPUT_0, sw_state)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Resetting preconditions for master device '%s' (Power off)", sw_state)
|
||||||
|
|
||||||
|
def test_color_temp_sync(self, tcel=report.TCEL_FULL):
|
||||||
|
self.tcl.testCase("Color temperature synchronisation test: %s" % self.ct_master.topic, tcel, self.__test_color_temp_sync__, tcel)
|
||||||
|
|
||||||
|
def __test_color_temp_sync__(self, tLogger, tcel):
|
||||||
|
sw_state = self.sw_master.get(self.sw_master.KEY_OUTPUT_0)
|
||||||
|
self.sw_master.set(self.sw_master.KEY_OUTPUT_0, True)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Setting preconditions for master device '%s' (Power on)", True)
|
||||||
|
|
||||||
|
target = self.follower[0].get(self.follower[0].KEY_COLOR_TEMP)
|
||||||
|
delta = 3 if target < 5 else -3
|
||||||
|
for i in range(0, 2):
|
||||||
|
target = target + delta
|
||||||
|
self.ct_master.set(self.br_master.KEY_COLOR_TEMP, target)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Changing master device color temperature to '%d'", target)
|
||||||
|
for fo in self.follower:
|
||||||
|
equivalency_chk(fo.get(fo.KEY_COLOR_TEMP), target, tLogger, "Follower device (%s) color temperature" % fo.topic)
|
||||||
|
delta = -delta
|
||||||
|
|
||||||
|
# reset changes of precondition
|
||||||
|
self.sw_master.set(self.sw_master.KEY_OUTPUT_0, sw_state)
|
||||||
|
time.sleep(DT_TOGGLE)
|
||||||
|
tLogger.debug("Resetting preconditions for master device '%s' (Power off)", sw_state)
|
1
unittest
Submodule
1
unittest
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit a73c8f8c3523df17eeddad6297d1454c16fc4552
|
Loading…
x
Reference in New Issue
Block a user