smart_brain_test/tests/__init__.py

44 lines
1.3 KiB
Python

import report
import simulation.devices
from unittest.test import equivalency_chk
DT_TOGGLE = 0.3
class test_collection(object):
def __init__(self, test_instance):
super().__init__()
self.test_instance = test_instance
def capabilities(self):
return ['full', 'smoke']
def command(self, command):
for member in self.test_instance.getmembers():
obj = self.test_instance.getobjbyname(member)
if id(obj) != id(self):
obj.test_all(report.TCEL_FULL if command == 'full' else report.TCEL_SMOKE)
class testcase(object):
def __init__(self):
super().__init__()
self.__test_list__ = []
def capabilities(self):
if len(self.__test_list__) > 0 and not 'test_all' in self.__test_list__:
self.__test_list__.append('test_all')
self.__test_list__.sort()
return self.__test_list__
def test_all(self, tcel=report.TCEL_FULL):
for tc_name in self.capabilities():
if tc_name != "test_all":
self.command(tc_name, tcel)
def command(self, command, tcel=report.TCEL_FULL):
simulation.devices.OUTPUT_ACTIVE = False
tc = getattr(self, command)
tc(tcel)
simulation.devices.OUTPUT_ACTIVE = True