From 3af018ca3e8290fc2847c3b38be15ee7b75b5b01 Mon Sep 17 00:00:00 2001 From: Tony Meyer Date: Thu, 30 May 2024 19:40:56 +1200 Subject: [PATCH 1/2] Fix broken files. --- scenario/mocking.py | 2 +- tests/helpers.py | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/scenario/mocking.py b/scenario/mocking.py index 841ca25a..ab2b1343 100644 --- a/scenario/mocking.py +++ b/scenario/mocking.py @@ -540,7 +540,7 @@ def action_get(self): def storage_add(self, name: str, count: int = 1): if not isinstance(count, int) or isinstance(count, bool): raise TypeError( - f"storage count must be integer, got: {count} ({type(count)})", + f"storage count must be integer, got: {count} ({type(count)}", ) if "/" in name: diff --git a/tests/helpers.py b/tests/helpers.py index c57ee171..64a747d6 100644 --- a/tests/helpers.py +++ b/tests/helpers.py @@ -56,3 +56,15 @@ def trigger( if post_event: post_event(mgr.charm) return state_out + + +def sort_patch(patch: List[Dict], key=lambda obj: obj["path"] + obj["op"]): + return sorted(patch, key=key) + + +def jsonpatch_delta(self, other: "State"): + patch = jsonpatch.make_patch( + dataclasses.asdict(other), + dataclasses.asdict(self), + ).patch + return sort_patch(patch) From 469de89315bb3cbd1bb8eb5a28eed73bbc7053c8 Mon Sep 17 00:00:00 2001 From: Tony Meyer Date: Thu, 30 May 2024 19:43:14 +1200 Subject: [PATCH 2/2] Update scenario/mocking.py --- scenario/mocking.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scenario/mocking.py b/scenario/mocking.py index ab2b1343..841ca25a 100644 --- a/scenario/mocking.py +++ b/scenario/mocking.py @@ -540,7 +540,7 @@ def action_get(self): def storage_add(self, name: str, count: int = 1): if not isinstance(count, int) or isinstance(count, bool): raise TypeError( - f"storage count must be integer, got: {count} ({type(count)}", + f"storage count must be integer, got: {count} ({type(count)})", ) if "/" in name: