@@ -43,7 +43,7 @@ class AlarmHandler(PayloadHandler):
#outdict = {}
full_payload=args[0]
#print(full_payload['alarms'])
#logging.debug(full_payload['alarms'])
currentAlarms=full_payload['alarms']#self.NativeUI.ongoingAlarms # instead of getting database at a particular frequency, this should be triggered when a new alarm arrives
@@ -156,14 +156,14 @@ class ModeHandler(PayloadHandler):
defcommandSent(self,key='CURRENT'):
self.commandList=[]
print('going to use ')
print(key)
logging.debug('going to use ')
logging.debug(key)
mode=self.get_mode(key)
ifmode=='CURRENT':
mode==self.NativeUI.currentMode
forwidgetinself.spinDict:
ifmode.replace("/","_").replace("-","_")inwidget.replace("/","_").replace("-","_"):#self.NativeUI.currentMode.replace("/", "_").replace("-", "_") in widget:
print('setting false '+widget)
logging.debug('setting false '+widget)
self.spinDict[widget].manuallyUpdated=False
forwidgetinself.mainSpinDict:
self.mainSpinDict[widget].manuallyUpdated=False
...
...
@@ -252,5 +252,5 @@ class ModeHandler(PayloadHandler):
- give NativeUI.get_updates() a fake payload of a high pressure alarm at high priority.
- that triggers NativeUI.set_alarms_db() which sets __alarms DB
- hev_alarms.updateAlarms() is run regularly to check for new alarms. When new alarms are added to NativeUI.__alarms hev_alarms.updateAlarms() triggers.
- hev_alarms.updateAlarms adds the alarm to the alarmDict, creates an alarm popup, and adds it to the alarm table displayed in the UI.
"""
# NativeUI.get_updates()
# NativeUI.set_alarms_db()
# __alarms DB Updated
# hev_alarms.updateAlarms()
# abstractAlarm
# TODO get a fake payload from the MCU side. Currently (8.4.21) not available as MCU and UI are not linked.
# - Sort Threading: In order to test the UI, the PyQT app needs to be running. This is controlled by app.exec_() (line 110), however when the app is running the main thread is locked out of firing off any other functions (i.e. test_high_pressure_alarm_high_priority()). Currently, the test_high_pressure_alarm_high_priority() test function runs in a secondary thread which doesn't interact with the app running in the main thread.
# - Assert that the __alarms DB is modified correctly (line 77-79)
The intention of this test is to solve the risk with Risk ID: SW11.
When excessive airway pressure is applied the microcontroller should send a High Pressure Alarm at a High Priority. This integration test tests from the point when that payload is fed into the UI. It will test that the payload will propgate through NativeUI app correctly and create a popup and add the alarm to the list of alarms.
Tests that giving NatviUI.get_updates a readback payload launches the expert, mode, and measurement handlers.
"""
# Set logging level to debug
caplog.set_level(logging.DEBUG)
# give NativeUI a personal payload
myNativeUI.get_updates(READBACK_JSON)
# Run test
assert"Expert handler"and"Measurement handler"incaplog.text,"The readback payload did not activate the expert, or measurement, or mode handler(s)."
# Clear logs
caplog.clear()
# Test that the other payloads don't trigger battery handler
payload_subset=[payloadforpayloadinpayloads]
payload_subset.remove(READBACK_JSON)
payload_subset.remove(DATA_JSON)
payload_subset.remove(TARGETS_JSON)
payload_subset.remove(CYCLE_JSON)
forpayloadinpayload_subset:
myNativeUI.get_updates(payload)
assert"Expert handler"and"Measurement handler"notincaplog.text,("The expert, or measurement, or mode handler(s) was activated by payload:",payload["type"])