81 lines
2.4 KiB
Python
81 lines
2.4 KiB
Python
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
|
|
# - Complete inter room functions
|
|
# - cleanup (e.g. bedlight dirk, christmas star, ...)
|
|
# - 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 control actions after amplifier on
|
|
# - Heating functionality (extended: mode switch off by other function, 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()
|
|
parser.add_argument("level", help="Set the execution level", choices=tcel.keys(), default="full")
|
|
args = parser.parse_args()
|
|
|
|
#
|
|
# MQTT Client
|
|
#
|
|
mc = mqtt.mqtt_client(host=config.MQTT_SERVER, port=config.MQTT_PORT, username=config.MQTT_USER,
|
|
password=config.MQTT_PASSWORD, name=config.APP_NAME)
|
|
#
|
|
# House instance
|
|
#
|
|
h = house(mc)
|
|
|
|
#
|
|
# Testsuite
|
|
#
|
|
test_level = tcel.get(args.level)
|
|
add_coverage = test_level == report.TCEL_FULL
|
|
ts = tests.help.testSession(mc, tcel=test_level)
|
|
# Add and run tests
|
|
tests.add_all_testcases(ts, mc, h)
|
|
|
|
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))
|
|
if add_coverage:
|
|
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) and add_coverage:
|
|
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")
|
|
)
|