فهرست منبع

Make sure there is a valid value for oadrResponseRequired

Stan Janssen 4 سال پیش
والد
کامیت
82c2b92cf1
1فایلهای تغییر یافته به همراه8 افزوده شده و 0 حذف شده
  1. 8 0
      openleadr/preflight.py

+ 8 - 0
openleadr/preflight.py

@@ -61,3 +61,11 @@ def preflight_oadrDistributeEvent(message_payload):
                 if event_signal['signal_name'] == "SIMPLE" and event['event_descriptor']['event_status'] != "ACTIVE":
                     warnings.warn("The current_value for a SIMPLE event that is not yet active must be 0. This will be corrected.")
                     event_signal['current_value'] = 0
+
+    # Check that there is a valid oadrResponseRequired value for each Event
+    for event in message_payload['events']:
+        if 'response_required' not in event:
+            event['response_required'] = 'always'
+        elif event['response_required'] not in ('never', 'always'):
+            warnings.warn(f"The response_required property in an Event should be 'never' or 'always', not {event['response_required']}. Changing to 'always'.")
+            event['response_required'] = 'always'