Skip to content

Commit cf599ac

Browse files
authored
IHS-170: Disable rich console print markup causing regex reformatting (#574)
* IHS-170: Disable rich console print markup causing regex reformatting * update tests
1 parent 7fbc329 commit cf599ac

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

changelog/565.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Disable rich console print markup causing regex reformatting

infrahub_sdk/ctl/schema.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ def display_schema_load_errors(response: dict[str, Any], schemas_data: list[Sche
7373
loc_type = loc_path[-1]
7474
input_str = error.get("input", None)
7575
error_message = f"{loc_type} ({input_str}) | {error['msg']} ({error['type']})"
76-
console.print(f" Node: {node.get('namespace', None)}{node.get('name', None)} | {error_message}")
76+
console.print(
77+
f" Node: {node.get('namespace', None)}{node.get('name', None)} | {error_message}", markup=False
78+
)
7779

7880
elif len(loc_path) > 6:
7981
loc_type = loc_path[5]
@@ -91,7 +93,9 @@ def display_schema_load_errors(response: dict[str, Any], schemas_data: list[Sche
9193

9294
input_str = error.get("input", None)
9395
error_message = f"{loc_type[:-1].title()}: {input_label} ({input_str}) | {error['msg']} ({error['type']})"
94-
console.print(f" Node: {node.get('namespace', None)}{node.get('name', None)} | {error_message}")
96+
console.print(
97+
f" Node: {node.get('namespace', None)}{node.get('name', None)} | {error_message}", markup=False
98+
)
9599

96100

97101
def handle_non_detail_errors(response: dict[str, Any]) -> None:

tests/unit/ctl/test_schema_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def test_schema_load_notvalid_namespace(httpx_mock: HTTPXMock) -> None:
116116
clean_output = remove_ansi_color(result.stdout.replace("\n", ""))
117117
expected_result = (
118118
"Unable to load the schema: Node: OuTDevice | "
119-
"namespace (OuT) | String should match pattern '^[A-Z]+$' (string_pattern_mismatch) "
119+
"namespace (OuT) | String should match pattern '^[A-Z][a-z0-9]+$' (string_pattern_mismatch) "
120120
" Node: OuTDevice | Attribute: name (NotValid) | Value error, Only valid Attribute Kind "
121121
"are : ['ID', 'Dropdown'] (value_error)"
122122
)

tests/unit/sdk/test_schema.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ async def test_display_schema_load_errors_details_namespace(mock_get_node) -> No
389389
mock_get_node.assert_called_once()
390390
output = console.file.getvalue()
391391
expected_console = """Unable to load the schema:
392-
Node: OuTInstance | namespace (OuT) | String should match pattern '^[A-Z]+$' (string_pattern_mismatch)
392+
Node: OuTInstance | namespace (OuT) | String should match pattern '^[A-Z][a-z0-9]+$' (string_pattern_mismatch)
393393
"""
394394
assert output == expected_console
395395

0 commit comments

Comments
 (0)