Index: tests/test_ui_proxy.py =================================================================== diff -u -r8ea13ae6dd10732bfcc456798f4785c4d88c95d3 -r3a4a3ca071c818acd40918e5d7a2400461e7cedb --- tests/test_ui_proxy.py (.../test_ui_proxy.py) (revision 8ea13ae6dd10732bfcc456798f4785c4d88c95d3) +++ tests/test_ui_proxy.py (.../test_ui_proxy.py) (revision 3a4a3ca071c818acd40918e5d7a2400461e7cedb) @@ -13,23 +13,59 @@ # @date (original) 21-Aug-2020 # ############################################################################ -import unittest import sys sys.path.append("../..") from dialin.hd.hemodialysis_device import HD +from time import sleep +from dialin.utils.base import AbstractObserver +IP_ADDRESS = "192.168.10.77" -class DGValves(unittest.TestCase): +class Observer(AbstractObserver): + def __init__(self): + self.valid = False - # @unittest.skip("Skipping test_imports") - def test_hd_get_reject_reasons(self): - hd = HD() + def update(self, message): + print(message) + self.valid = message.get("treatment_parameters_valid", False) - i = 0 - for key, value in hd.ui.get_reject_reasons().items(): - self.assertEqual(i, value) - i += 1 +def test_create_treatment(): + hd = HD(log_level="DEBUG") + hd.cmd_hd_software_reset_request() + observer = Observer() + hd.ui.attach(observer) + sleep(1) + if hd.cmd_log_in_to_hd(): + sleep(10) + print("Logged in") + hd.ui.cmd_ui_start_treatment_request(0) + sleep(4) + hd.ui.cmd_set_treatment_parameters(100, 100, 120, 0, 0, 0, 100, 1, 0, 1, 36, -200, -170, -100, 100, 30, 75) + while not observer.valid: + sleep(0.1) + hd.ui.cmd_ui_confirm_treatment_parameters() + sleep(4) + hd.ui.cmd_ui_start_treatment_request(2) + sleep(4) +def test_reset_hd(): + hd = HD(log_level="DEBUG") + hd.cmd_hd_software_reset_request() +def test_get_hd_operation_mode(): + hd = HD(log_level="DEBUG") + observer = Observer() + hd.ui.attach(observer) + if hd.cmd_log_in_to_hd(): + sleep(5) + print(hd.get_operation_mode()) + +def test_clear_all_alarms(): + hd = HD(log_level="DEBUG") + hd.alarms.cmd_clear_all_alarms() + if __name__ == '__main__': - sys.exit(unittest.main(verbosity=2).result.wasSuccessful()) + # test_reset_hd() + # test_create_treatment() + test_clear_all_alarms() + # test_get_hd_operation_mode()