adaption to updated devdi + coverage added + smoke, short implementaion

This commit is contained in:
Dirk Alders 2025-08-29 21:08:32 +02:00
parent d7eceb30ce
commit 5b7257a730
13 changed files with 105 additions and 133414 deletions

3
.gitmodules vendored
View File

@ -13,9 +13,6 @@
[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

View File

@ -2,32 +2,39 @@ OUTDIR=testresults
TEXFILE=$(OUTDIR)/testrun.tex
PDFFILE=$(OUTDIR)/testrun.pdf
TEXFILE_FULL=$(OUTDIR)/testrun_full.tex
PDFFILE_FULL=$(OUTDIR)/testrun_full.pdf
smoke: test_smoke pdf view pdf_full clean
release:
cp -v $(PDFFILE) ../smart_brain/_testresults_
cp -v $(OUTDIR)/testrun.json ../smart_brain/_testresults_
cp -v $(OUTDIR)/coverage.xml ../smart_brain/_testresults_
single: test_single pdf view clean
@echo FINISHED...
short: test_short pdf view pdf_full clean
smoke: test_smoke pdf view clean
@echo FINISHED...
full: test_full pdf view pdf_full clean
short: test_short pdf view clean
@echo FINISHED...
full: test_full pdf view clean
@echo FINISHED...
test_single:
venv/bin/python smart_brain_test.py single
test_smoke:
venv/bin/python smart_brain_test.py test.all.smoke
venv/bin/python smart_brain_test.py smoke
test_short:
venv/bin/python smart_brain_test.py test.all.short
venv/bin/python smart_brain_test.py short
test_full:
venv/bin/python smart_brain_test.py test.all.full
venv/bin/python smart_brain_test.py 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)
@ -40,6 +47,3 @@ localclean:
@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

2
devdi

@ -1 +1 @@
Subproject commit 4fa00811c6d243888828e67b0952b5b06f46a3d7
Subproject commit f0b994ef9c3a0526c4b699c491ccb478bc3847d0

View File

@ -56,6 +56,23 @@ def remote(mqtt_client, topic):
def my_ambient(mqtt_client, topic):
logger.warning("Device type my_ambient is not yet implemented. Topic %s will not be supported", topic)
return None
def videv_pure_switch(mqtt_client, topic):
logger.warning("Device type videv_pure_switch is not yet implemented. Topic %s will not be supported", topic)
return None
def videv_multistate(mqtt_client, topic):
logger.warning("Device type videv_multistate is not yet implemented. Topic %s will not be supported", topic)
return None
def videv_audio_player(mqtt_client, topic):
logger.warning("Device type videv_audio_player is not yet implemented. Topic %s will not be supported", topic)
return None
# TODO: Not yet implemented devices ###################################
@ -148,14 +165,25 @@ class livarno_sw_br_ct(tradfri_light):
class videv_sw(videv_light):
def __init__(self, mqtt_client, topic):
super().__init__(mqtt_client, topic, True, False, False)
super().__init__(mqtt_client, topic, True, False, False, False)
class videv_sw_br(videv_light):
def __init__(self, mqtt_client, topic):
super().__init__(mqtt_client, topic, True, True, False)
super().__init__(mqtt_client, topic, True, True, False, False)
class videv_sw_br_ct(videv_light):
def __init__(self, mqtt_client, topic):
super().__init__(mqtt_client, topic, True, True, True)
super().__init__(mqtt_client, topic, True, True, True, False)
class videv_sw_tm(videv_light):
def __init__(self, mqtt_client, topic):
super().__init__(mqtt_client, topic, True, True, True, True)
class videv_sw_mo(videv_light):
# TODO: Motion functions not included yet
def __init__(self, mqtt_client, topic):
super().__init__(mqtt_client, topic, True, True, True, True)

@ -1 +1 @@
Subproject commit c10e8792abb05671dab6de51cdadda3bf8ead50f
Subproject commit 22f5af3bca4e4125ee92d30f7797590116188fab

2
geo

@ -1 +1 @@
Subproject commit 11166bb27ad2335f7812fcb88c788397f5106751
Subproject commit edc3c9975ec723abf81e9ba52b4012f4674f3ac5

1
reqif

@ -1 +0,0 @@
Subproject commit c0e8533af5eeb4dccb6cd8742c936eb456ce6466

View File

@ -1,29 +1,40 @@
import argparse
import config
from devdi.topic import STOP_EXECUTION_TOPIC
import json
import mqtt
from simulation.rooms import house
import report
import unittest
import os
import time
import tests.help
# TODO: Extend tests in simulation
# - Add cross room functions like follow input_1 -> floor light
# - Compare with nodered capabilities
# - Add furthet heating checks (set to default, ...)
# - Test???: Check of warning messages for battery and overtemperature
# - cleanup (e.g. bedlight dirk, christmas star, ...)
# - circ pump on -> flash
# - Longpress -> flash
# - All off
# - circulation pump -> timer
# - stairway on -> timer
# - stairway motion -> feedback in videv / switch on light
# - Switching button functions (gfw_dirk, ffe.sleep)
# - Brightness button functions (gfw.dirk, ffe.sleep)
# - Remote actions after amplifier on
# - Remote control actions after amplifier on
# - Heating functionality (extended: mode switch off by other function, timer)
# - Circulation pump (Extend Timer)
# - Stairways (Extend Motion sensor and Timer)
# - Inspect coverage result for important checks
if __name__ == "__main__":
# Command line arguments
tcel = {
"single": report.TCEL_SINGLE,
"smoke": report.TCEL_SMOKE,
"short": report.TCEL_SHORT,
"full": report.TCEL_FULL
}
parser = argparse.ArgumentParser()
@ -46,8 +57,23 @@ if __name__ == "__main__":
ts = tests.help.testSession(mc, tcel=tcel.get(args.level))
# Add and run tests
tests.add_all_testcases(ts, mc, h)
# Export testresults
BASEPATH = os.path.abspath(os.path.join(os.path.dirname(__file__)))
#
# Add coverage data
#
# Stop smart_brain execution
mc.send(STOP_EXECUTION_TOPIC, json.dumps(True))
time.sleep(2) # give smart_brain time to create coverage xml file
#
coverage_file = os.path.join(BASEPATH, "testresults", "coverage.xml")
if os.path.exists(coverage_file):
ts.full_test_data[unittest.jsonlog.MAIN_KEY_COVERAGE_INFO] = unittest.run.coverage_info(coverage_file, None)
#
# Export testresults
#
ts.export_results_to(
template_file=os.path.join(BASEPATH, 'unittest', 'templates', 'unittest.tex'),
path=os.path.join(BASEPATH, "testresults")

2
task

@ -1 +1 @@
Subproject commit af35e83d1f07fd4cb9070bdb77cf1f3bdda3a463
Subproject commit bb6f7ea26f24481cba7218256e47572fa84db478

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -1,4 +1,5 @@
import config
import random
import report
import time
@ -10,6 +11,10 @@ from .help import STATES_SW, STATES_BR, STATES_CT, STATES_TEMP
from tests.common_testcases import device_follow
def rand_tcel():
return random.choice(5 * [report.TCEL_FULL] + 3 * [report.TCEL_SHORT] + 2 * [report.TCEL_SMOKE])
def device_follow_sw(ts, master, slave, master_ch=0, slave_ch=0, single=False):
master_key = getattr(master, "KEY_OUTPUT_%d" % master_ch)
slave_key = getattr(slave, "KEY_OUTPUT_%d" % slave_ch)
@ -19,7 +24,7 @@ def device_follow_sw(ts, master, slave, master_ch=0, slave_ch=0, single=False):
#
testcase_id = master_name + " -> " + slave_name
ts.testCase(
testcase_id, report.TCEL_SINGLE if single else report.TCEL_SMOKE, device_follow,
testcase_id, report.TCEL_SINGLE if single else rand_tcel(), device_follow,
master, master_key,
slave, slave_key,
STATES_SW, None
@ -32,7 +37,7 @@ def device_follow_br(ts, master, slave, switch_on=None, single=False):
#
testcase_id = master_name + " -> " + slave_name
ts.testCase(
testcase_id, report.TCEL_SINGLE if single else report.TCEL_SMOKE, device_follow,
testcase_id, report.TCEL_SINGLE if single else rand_tcel(), device_follow,
master, master.KEY_BRIGHTNESS,
slave, slave.KEY_BRIGHTNESS,
STATES_BR, switch_on
@ -45,7 +50,7 @@ def device_follow_ct(ts, master, slave, switch_on=None, single=False):
#
testcase_id = master_name + " -> " + slave_name
ts.testCase(
testcase_id, report.TCEL_SINGLE if single else report.TCEL_SMOKE, device_follow,
testcase_id, report.TCEL_SINGLE if single else rand_tcel(), device_follow,
master, master.KEY_COLOR_TEMP,
slave, slave.KEY_COLOR_TEMP,
STATES_CT, switch_on
@ -58,7 +63,7 @@ def device_follow_temp(ts, master, slave, single=False):
#
testcase_id = master_name + " -> " + slave_name
ts.testCase(
testcase_id, report.TCEL_SINGLE if single else report.TCEL_SMOKE, device_follow,
testcase_id, report.TCEL_SINGLE if single else rand_tcel(), device_follow,
master, master.KEY_USER_TEMPERATURE_SETPOINT,
slave, slave.KEY_TEMPERATURE_SETPOINT,
STATES_TEMP, None
@ -269,18 +274,18 @@ def gfw(ts: testSession, mc: mqtt_client, h: house):
device_follow_sw(ts, room.videv_pc_dock, room.switch_pc_dock)
device_follow_sw(ts, room.switch_pc_dock, room.videv_pc_dock)
# powerplug videv <-> channel
device_follow_sw(ts, room.videv_amplifier, room.my_powerplug, slave_ch=0)
device_follow_sw(ts, room.my_powerplug, room.videv_amplifier, master_ch=0)
device_follow_sw(ts, room.videv_phono, room.my_powerplug, slave_ch=1)
device_follow_sw(ts, room.my_powerplug, room.videv_phono, master_ch=1)
device_follow_sw(ts, room.videv_cd_player, room.my_powerplug, slave_ch=2)
device_follow_sw(ts, room.my_powerplug, room.videv_cd_player, master_ch=2)
device_follow_sw(ts, room.videv_bluetooth, room.my_powerplug, slave_ch=3)
device_follow_sw(ts, room.my_powerplug, room.videv_bluetooth, master_ch=3)
device_follow_sw(ts, room.videv_amplifier, room.switch_powerplug_4, slave_ch=0)
device_follow_sw(ts, room.switch_powerplug_4, room.videv_amplifier, master_ch=0)
device_follow_sw(ts, room.videv_phono, room.switch_powerplug_4, slave_ch=1)
device_follow_sw(ts, room.switch_powerplug_4, room.videv_phono, master_ch=1)
device_follow_sw(ts, room.videv_cd_player, room.switch_powerplug_4, slave_ch=2)
device_follow_sw(ts, room.switch_powerplug_4, room.videv_cd_player, master_ch=2)
device_follow_sw(ts, room.videv_bluetooth, room.switch_powerplug_4, slave_ch=3)
device_follow_sw(ts, room.switch_powerplug_4, room.videv_bluetooth, master_ch=3)
# powerplug follow
device_follow_sw(ts, room.my_powerplug, room.my_powerplug, master_ch=1, slave_ch=0)
device_follow_sw(ts, room.my_powerplug, room.my_powerplug, master_ch=2, slave_ch=0)
device_follow_sw(ts, room.my_powerplug, room.my_powerplug, master_ch=3, slave_ch=0)
device_follow_sw(ts, room.switch_powerplug_4, room.switch_powerplug_4, master_ch=1, slave_ch=0)
device_follow_sw(ts, room.switch_powerplug_4, room.switch_powerplug_4, master_ch=2, slave_ch=0)
device_follow_sw(ts, room.switch_powerplug_4, room.switch_powerplug_4, master_ch=3, slave_ch=0)
# Brightness and Colortemperature ####################
device_follow_br(ts, room.videv_main_light, room.light_main_light, room.switch_main_light)
device_follow_br(ts, room.light_main_light, room.videv_main_light, room.switch_main_light)

@ -1 +1 @@
Subproject commit e5282ac16addbe4d6e59f4a7accaac6b73b469ee
Subproject commit e3073141d24c0cd4681b6c57a0967a5506fb35e8