test: don't allow the deprecated LedTypes field

This commit is contained in:
Yaroslav Chvanov
2023-02-25 13:39:47 +03:00
parent ac999da26c
commit 274f19e84b

View File

@@ -69,42 +69,17 @@ def check_devicetype_str(string):
assertIn(string, permitted_types)
def check_ledtypes_str(string: str):
permitted_types = [
'battery',
'dpi',
'logo',
'side',
'switches',
'wheel',
]
types = string.split(';')
for t in types:
if not t: # empty string if trailing ;
continue
assertIn(t, permitted_types)
def check_section_device(section: configparser.SectionProxy):
required_keys = ['Name', 'Driver', 'DeviceMatch', 'DeviceType']
permitted_keys = required_keys + ['LedTypes']
for key in section.keys():
assertIn(key, permitted_keys)
assertIn(key, required_keys)
for r in required_keys:
assertIn(r, section)
check_devicetype_str(section['DeviceType'])
try:
check_ledtypes_str(section['LedTypes'])
except KeyError:
# No such section - not an error.
pass
check_match_str(section['DeviceMatch'])