From 7571b1764a1514cdc1e7b6fcd6dab49eb3f3a357 Mon Sep 17 00:00:00 2001 From: Dima Tisnek Date: Fri, 10 Jan 2025 14:05:03 +0900 Subject: [PATCH 1/2] chore: test #1111 --- juju/client/facade.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/juju/client/facade.py b/juju/client/facade.py index c3b2e2c5..f4215854 100644 --- a/juju/client/facade.py +++ b/juju/client/facade.py @@ -684,6 +684,7 @@ async def rpc(self, msg: dict[str, _RichJson]) -> _Json: def from_json(cls, data: Type | str | dict[str, Any] | list[Any]) -> Self | None: def _parse_nested_list_entry(expr, result_dict): if isinstance(expr, str): + raise Exception(f"Ouch {expr=}") if ">" in expr or ">=" in expr: # something like juju >= 2.9.31 i = expr.index(">") @@ -694,9 +695,11 @@ def _parse_nested_list_entry(expr, result_dict): # this is a simple entry result_dict[expr] = "" elif isinstance(expr, dict): + raise Exception(f"Ouch {expr=}") for v in expr.values(): _parse_nested_list_entry(v, result_dict) elif isinstance(expr, list): + raise Exception(f"Ouch {expr=}") for v in expr: _parse_nested_list_entry(v, result_dict) else: From e23f821b45db4f67424adc9c03b67dc281472c0f Mon Sep 17 00:00:00 2001 From: Dima Tisnek Date: Fri, 10 Jan 2025 15:58:17 +0900 Subject: [PATCH 2/2] chore: document the test vectors --- juju/client/facade.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/juju/client/facade.py b/juju/client/facade.py index f4215854..83347fcf 100644 --- a/juju/client/facade.py +++ b/juju/client/facade.py @@ -683,7 +683,9 @@ async def rpc(self, msg: dict[str, _RichJson]) -> _Json: @classmethod def from_json(cls, data: Type | str | dict[str, Any] | list[Any]) -> Self | None: def _parse_nested_list_entry(expr, result_dict): + # FIXME if no client uses this data, can we drop this? if isinstance(expr, str): + # FIXME no top-level use raise Exception(f"Ouch {expr=}") if ">" in expr or ">=" in expr: # something like juju >= 2.9.31 @@ -695,11 +697,15 @@ def _parse_nested_list_entry(expr, result_dict): # this is a simple entry result_dict[expr] = "" elif isinstance(expr, dict): + # FIXME no top-level use raise Exception(f"Ouch {expr=}") for v in expr.values(): _parse_nested_list_entry(v, result_dict) elif isinstance(expr, list): - raise Exception(f"Ouch {expr=}") + # FIXME test vectors from quarantined integration tests + # expr=['juju', {'any-of': [{'all-of': ['juju >= 2.9.49', 'juju < 3']}, {'all-of': ['juju >= 3.4.3', 'juju < 3.5']}, {'all-of': ['juju >= 3.5.1', 'juju < 4']}]}] + # expr=['juju', {'any-of': [{'all-of': ['juju >= 2.9.44', 'juju < 3']}, {'all-of': ['juju >= 3.4.3', 'juju < 4']}]}] + # expr=['juju', {'any-of': [{'all-of': ['juju >= 2.9.44', 'juju < 3']}, {'all-of': ['juju >= 3.4.3', 'juju < 4']}]}] for v in expr: _parse_nested_list_entry(v, result_dict) else: