mbj4668 / pyang

An extensible YANG validator and converter in python
ISC License
530 stars 342 forks source link

check_update does not validate 'when' constraints for YANG 1.1 models #847

Closed dingrouv closed 1 year ago

dingrouv commented 1 year ago

check_update.py's chk_when() checks for newly added/changed 'when' constraints and should emit CHK_NEW_WHEN/CHK_UNDECIDED_WHEN errors.

After updating to YANG 1.1 we found that check_update does not report new/changed when constraints properly.

This PR includes a simple fix to chk_when() (changes elif to if) so that errors are properly reported. It also adds a test case for a new/changed when constraints in a 1.1 model.

UT Results With UT changes but without chk_when() fix we see that the expected errors are not produced

trying a... ok
trying c... ok
trying f... ok
trying h... ok
trying i... ok
trying j...2,3d1
< j@2014-04-01.yang:14: error: CHK_NEW_WHEN
< j@2014-04-01.yang:18: warning: CHK_UNDECIDED_WHEN
make: *** [test] Error 1

With chk_when() fix:

> make
trying a... ok
trying c... ok
trying f... ok
trying h... ok
trying i... ok
trying j... ok
trying k... ok
trying c+d... ok
trying c+e... ok
(venv)