Skip to content

Commit 7ed1f14

Browse files
committed
Improve the mismatched category issue message
Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 214d0e4 commit 7ed1f14

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/frequenz/client/microgrid/component/_component_proto.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,10 @@ def component_base_from_proto_with_issues(
179179
and isinstance(category, ComponentCategory)
180180
and category.name.lower() != category_specific_info_kind
181181
):
182-
major_issues.append("category_type.metadata does not match the category_type")
182+
major_issues.append(
183+
f"category_specific_info.kind ({category_specific_info_kind}) does not "
184+
f"match the category ({category.name.lower()})",
185+
)
183186
category_mismatched = True
184187

185188
return ComponentBaseData(

tests/component/component_proto/test_base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ def test_category_specific_info_mismatch(
9191
proto, major_issues=major_issues, minor_issues=minor_issues
9292
)
9393
# Actual message from _component_base_from_proto_with_issues
94-
assert major_issues == ["category_type.metadata does not match the category_type"]
94+
assert major_issues == [
95+
"category_specific_info.kind (battery) does not match the category (grid_connection_point)"
96+
]
9597
assert not minor_issues
9698
assert parsed == base_data
9799

tests/component/component_proto/test_simple.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ def test_category_mismatch(default_component_base_data: ComponentBaseData) -> No
9292
)
9393
# The actual message from component_from_proto_with_issues via
9494
# _component_base_from_proto_with_issues
95-
assert major_issues == ["category_type.metadata does not match the category_type"]
95+
assert major_issues == [
96+
"category_specific_info.kind (battery) does not match the category (grid_connection_point)"
97+
]
9698
assert not minor_issues
9799
assert isinstance(component, MismatchedCategoryComponent)
98100
assert_base_data(base_data, component)

0 commit comments

Comments
 (0)