Skip to content

Commit 3a8d901

Browse files
committed
Use function for snake case conversion
1 parent ed8e2bf commit 3a8d901

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

etc/kayobe/ansible/scripts/test_smartmon.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
parse_device_info,
1111
parse_if_attributes,
1212
main,
13-
SMARTMON_ATTRS
13+
SMARTMON_ATTRS,
14+
camel_to_snake
1415
)
1516

1617
def load_json_fixture(filename):
@@ -158,8 +159,7 @@ def _test_parse_if_attributes(self, fixture_name):
158159
# For each numeric attribute in JSON, if it's in SMARTMON_ATTRS,
159160
# we expect a line in the script's output.
160161
for attr_key, attr_val in if_attrs.items():
161-
# Convert from e.g. "criticalWarning" -> "critical_warning"
162-
snake_key = re.sub(r'(?<!^)(?=[A-Z])', '_', attr_key).lower()
162+
snake_key = camel_to_snake(attr_key)
163163

164164
if isinstance(attr_val, (int, float)) and snake_key in SMARTMON_ATTRS:
165165
# We expect e.g. critical_warning{disk="/dev/..."} <value>

0 commit comments

Comments
 (0)