Test Smart Brain implementation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

__init__.py 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import report
  2. import simulation.devices
  3. from unittest.test import equivalency_chk
  4. from unittest.jsonlog import TRUN_EXEC_LVL
  5. DT_TOGGLE = 0.3
  6. class test_collection(object):
  7. TCEL_DICT = {
  8. 'full': report.TCEL_FULL,
  9. 'short': report.TCEL_SHORT,
  10. 'smoke': report.TCEL_SMOKE
  11. }
  12. def __init__(self, test_instance):
  13. super().__init__()
  14. self.test_instance = test_instance
  15. def capabilities(self):
  16. return ['full', 'short', 'smoke']
  17. def command(self, command):
  18. for member in self.test_instance.getmembers():
  19. obj = self.test_instance.getobjbyname(member)
  20. if id(obj) != id(self):
  21. tcel = self.TCEL_DICT.get(command, report.TCEL_FULL)
  22. self.test_instance.tcl[TRUN_EXEC_LVL] = tcel
  23. obj.test_all(tcel)
  24. class testcase(object):
  25. METHOD_EXECUTED = {}
  26. def __init__(self, tcl):
  27. self.tcl = tcl
  28. self.__test_list__ = []
  29. def capabilities(self):
  30. if len(self.__test_list__) > 0 and not 'test_all' in self.__test_list__:
  31. self.__test_list__.append('test_all')
  32. self.__test_list__.sort()
  33. return self.__test_list__
  34. def test_all(self, tcel=report.TCEL_FULL):
  35. for tc_name in self.capabilities():
  36. if tc_name != "test_all":
  37. self.command(tc_name, tcel)
  38. def command(self, command, tcel=report.TCEL_SINGLE):
  39. simulation.devices.OUTPUT_ACTIVE = False
  40. tc = getattr(self, command)
  41. self.tcl[TRUN_EXEC_LVL] = tcel
  42. tc(tcel)
  43. simulation.devices.OUTPUT_ACTIVE = True