File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed
Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -31,9 +31,11 @@ def _set_out_defaults(fields):
3131 fields .setdefault ('OMSL' , 'supervisory' )
3232
3333def _set_alarm (fields ):
34- if "status" in fields :
34+ if 'status' in fields :
35+ assert 'STAT' not in fields , 'Can\' t specify both status and STAT'
3536 fields ['STAT' ] = _statStrings [fields .pop ('status' )]
36- if "severity" in fields :
37+ if 'severity' in fields :
38+ assert 'SEVR' not in fields , 'Can\' t specify both severity and SEVR'
3739 fields ['SEVR' ] = _severityStrings [fields .pop ('severity' )]
3840
3941# For longout and ao we want DRV{L,H} to match {L,H}OPR by default
Original file line number Diff line number Diff line change @@ -197,6 +197,36 @@ def test_setting_alarm_in_records(creation_func):
197197 assert record .STAT .Value () == "LOLO"
198198 assert record .SEVR .Value () == "MINOR"
199199
200+ @pytest .mark .parametrize ("creation_func" , in_records )
201+ def test_setting_alarm_invalid_keywords (creation_func ):
202+ """Test that In records correctly block specifying both STAT and status,
203+ and SEVR and severity"""
204+
205+ kwargs = {}
206+ if creation_func == builder .WaveformIn :
207+ kwargs ["length" ] = 1
208+
209+ with pytest .raises (AssertionError ) as e :
210+ creation_func (
211+ "NEW_RECORD" ,
212+ severity = alarm .MINOR_ALARM ,
213+ SEVR = "MINOR" ,
214+ status = alarm .LOLO_ALARM ,
215+ ** kwargs
216+ )
217+
218+ assert e .value .args [0 ] == 'Can\' t specify both severity and SEVR'
219+
220+ with pytest .raises (AssertionError ) as e :
221+ creation_func (
222+ "NEW_RECORD" ,
223+ severity = alarm .MINOR_ALARM ,
224+ status = alarm .LOLO_ALARM ,
225+ STAT = "LOLO" ,
226+ ** kwargs
227+ )
228+
229+ assert e .value .args [0 ] == 'Can\' t specify both status and STAT'
200230
201231
202232def validate_fixture_names (params ):
You can’t perform that action at this time.
0 commit comments