Index: DialysateGenerator.py =================================================================== diff -u -r921425cec163072566cf7d269474c4f28f9725c4 -r939a86a215a1a244e493c6455292d921a77698e3 --- DialysateGenerator.py (.../DialysateGenerator.py) (revision 921425cec163072566cf7d269474c4f28f9725c4) +++ DialysateGenerator.py (.../DialysateGenerator.py) (revision 939a86a215a1a244e493c6455292d921a77698e3) @@ -26,10 +26,6 @@ """ -def PublicationReceiverHandler(message): - print(".", end='', flush=True) - - class DG: """ \class DG @@ -59,7 +55,8 @@ self.__can_interface = DenaliCanMessenger(can_interface=can__interface) self.__can_interface.registerReceivingPublicationFunction(channel_id=DenaliChannels.dg_sync_broadcast_ch_id, message_id=self.DG_MSG_ID_BROADCAST, - function=PublicationReceiverHandler) + function=( + lambda message: print(".", end='', flush=True))) self.__can_interface.start() def fill(self, start_or_stop='start'): @@ -70,7 +67,6 @@ \returns True if ran the command, False otherwise, returns None if timeout """ - payload = [1] if start_or_stop == 'start' else [0] msg = DenaliMessage.buildMessage(channel_id=DenaliChannels.hd_to_dg_ch_id, @@ -87,30 +83,27 @@ return returnValue -def test_fill_print(msg): - if msg is not None: - print("f", end='', flush=True) - else: - print("t", end='', flush=True) +def test_dg_start(): + dg = DG() + sleep(2) + resp = dg.fill('start') + test_passed = isinstance(resp, bool) + if test_passed: + print("DG started and DG response is {}".format(test_passed)) -if __name__ == "__main__": - test_dg = DG() + assert test_passed + +def test_dg_stop(): + dg = DG() + sleep(1) + dg.fill('start') sleep(2) - test_packet = test_dg.fill('start') - test_fill_print(test_packet) + resp = dg.fill('stop') + test_passed = isinstance(resp, bool) - sleep(10) - test_packet = test_dg.fill('stop') - test_fill_print(test_packet) + if test_passed: + print("DG started/stopped and DG response is {}".format(test_passed)) -# del test_dg - -# sleep(1) -# test_packet = test_dg.fill('start') -# test_fill_print(test_packet) - -# sleep(2) -# test_packet = test_dg.fill('start') -# test_fill_print(test_packet) + assert test_passed