151 lines
8.1 KiB
Python
151 lines
8.1 KiB
Python
import config
|
|
import inspect
|
|
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):
|
|
super().__init__(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):
|
|
fname = inspect.currentframe().f_code.co_name
|
|
if tcel != report.TCEL_SMOKE or not self.METHOD_EXECUTED.get(fname, False):
|
|
self.METHOD_EXECUTED[fname] = True
|
|
#
|
|
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):
|
|
fname = inspect.currentframe().f_code.co_name
|
|
if tcel != report.TCEL_SMOKE or not self.METHOD_EXECUTED.get(fname, False):
|
|
self.METHOD_EXECUTED[fname] = True
|
|
#
|
|
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):
|
|
fname = inspect.currentframe().f_code.co_name
|
|
if tcel != report.TCEL_SMOKE or not self.METHOD_EXECUTED.get(fname, False):
|
|
self.METHOD_EXECUTED[fname] = True
|
|
#
|
|
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):
|
|
fname = inspect.currentframe().f_code.co_name
|
|
if tcel != report.TCEL_SMOKE or not self.METHOD_EXECUTED.get(fname, False):
|
|
self.METHOD_EXECUTED[fname] = True
|
|
#
|
|
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):
|
|
fname = inspect.currentframe().f_code.co_name
|
|
if tcel != report.TCEL_SMOKE or not self.METHOD_EXECUTED.get(fname, False):
|
|
self.METHOD_EXECUTED[fname] = True
|
|
#
|
|
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
|