add more tests and fixes for command inheritance

- fix CommandType.__repr__
- secop/modules.py: command properties are allowed to be configured:
  - section 2: remove comment and rename
  - section 3: all accessible properties should be checked
- command description should be inherited also when taken from docstring
- move test for command inheritance to test_modules.py
- added tests to check for valid properties of commands

Change-Id: Ic7795e305048625558e415ece099e6824df6e2c4
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/27135
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
2021-11-12 15:00:08 +01:00
parent 1d75d192e5
commit c91d726f9d
5 changed files with 127 additions and 48 deletions

View File

@ -322,26 +322,23 @@ class Module(HasAccessibles):
# 2) check and apply parameter_properties
# specified as '<paramname>.<propertyname> = <propertyvalue>'
# this may also be done on commands: e.g. 'stop.visibility = advanced'
for k, v in list(cfgdict.items()): # keep list() as dict may change during iter
if '.' in k[1:]:
paramname, propname = k.split('.', 1)
aname, propname = k.split('.', 1)
propvalue = cfgdict.pop(k)
paramobj = self.accessibles.get(paramname, None)
# paramobj might also be a command (not sure if this is needed)
if paramobj:
# no longer needed, this conversion is done by DataTypeType.__call__:
# if propname == 'datatype':
# propvalue = get_datatype(propvalue, k)
aobj = self.accessibles.get(aname, None)
if aobj:
try:
paramobj.setProperty(propname, propvalue)
aobj.setProperty(propname, propvalue)
except KeyError:
errors.append("'%s.%s' does not exist" %
(paramname, propname))
(aname, propname))
except BadValueError as e:
errors.append('%s.%s: %s' %
(paramname, propname, str(e)))
(aname, propname, str(e)))
else:
errors.append('%r not found' % paramname)
errors.append('%r not found' % aname)
# 3) check config for problems:
# only accept remaining config items specified in parameters
@ -427,11 +424,11 @@ class Module(HasAccessibles):
self.checkProperties()
except ConfigError as e:
errors.append(str(e))
for pname, p in self.parameters.items():
for aname, aobj in self.accessibles.items():
try:
p.checkProperties()
except ConfigError as e:
errors.append('%s: %s' % (pname, e))
aobj.checkProperties()
except (ConfigError, ProgrammingError) as e:
errors.append('%s: %s' % (aname, e))
if errors:
raise ConfigError(errors)