From c26e0591dffe091c80392247158198b08c35efd0 Mon Sep 17 00:00:00 2001 From: Tony Meyer Date: Wed, 7 Aug 2024 15:20:42 +1200 Subject: [PATCH] Go back to making only one content positional. --- scenario/state.py | 2 +- tests/test_context_on.py | 8 ++++---- tests/test_e2e/test_secrets.py | 17 ++++++++--------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/scenario/state.py b/scenario/state.py index 76819ee5..c873b1d4 100644 --- a/scenario/state.py +++ b/scenario/state.py @@ -280,7 +280,7 @@ def _generate_secret_id(): @dataclasses.dataclass(frozen=True) -class Secret(_max_posargs(2)): +class Secret(_max_posargs(1)): tracked_content: "RawSecretRevisionContents" latest_content: Optional["RawSecretRevisionContents"] = None diff --git a/tests/test_context_on.py b/tests/test_context_on.py index c74b0185..8ddbf4d4 100644 --- a/tests/test_context_on.py +++ b/tests/test_context_on.py @@ -112,8 +112,8 @@ def test_simple_secret_events(as_kwarg, event_name, event_kind, owner): def test_revision_secret_events(event_name, event_kind): ctx = scenario.Context(ContextCharm, meta=META, actions=ACTIONS) secret = scenario.Secret( - {"password": "yyyy"}, - {"password": "xxxx"}, + tracked_content={"password": "yyyy"}, + latest_content={"password": "xxxx"}, owner="app", ) state_in = scenario.State(secrets={secret}) @@ -135,8 +135,8 @@ def test_revision_secret_events(event_name, event_kind): def test_revision_secret_events_as_positional_arg(event_name): ctx = scenario.Context(ContextCharm, meta=META, actions=ACTIONS) secret = scenario.Secret( - {"password": "yyyy"}, - {"password": "xxxx"}, + tracked_content={"password": "yyyy"}, + latest_content={"password": "xxxx"}, owner=None, ) state_in = scenario.State(secrets={secret}) diff --git a/tests/test_e2e/test_secrets.py b/tests/test_e2e/test_secrets.py index b8f88dab..5983c7df 100644 --- a/tests/test_e2e/test_secrets.py +++ b/tests/test_e2e/test_secrets.py @@ -1,5 +1,4 @@ import datetime -import warnings import pytest from ops.charm import CharmBase @@ -69,8 +68,8 @@ def test_get_secret_get_refresh(mycharm, owner): def test_get_secret_nonowner_peek_update(mycharm, app): ctx = Context(mycharm, meta={"name": "local"}) secret = Secret( - {"a": "b"}, - {"a": "c"}, + tracked_content={"a": "b"}, + latest_content={"a": "c"}, ) with ctx.manager( ctx.on.update_status(), @@ -95,8 +94,8 @@ def test_get_secret_nonowner_peek_update(mycharm, app): def test_get_secret_owner_peek_update(mycharm, owner): ctx = Context(mycharm, meta={"name": "local"}) secret = Secret( - {"a": "b"}, - {"a": "c"}, + tracked_content={"a": "b"}, + latest_content={"a": "c"}, owner=owner, ) with ctx.manager( @@ -119,8 +118,8 @@ def test_get_secret_owner_peek_update(mycharm, owner): def test_secret_changed_owner_evt_fails(mycharm, owner): ctx = Context(mycharm, meta={"name": "local"}) secret = Secret( - {"a": "b"}, - {"a": "c"}, + tracked_content={"a": "b"}, + latest_content={"a": "c"}, owner=owner, ) with pytest.raises(ValueError): @@ -138,8 +137,8 @@ def test_secret_changed_owner_evt_fails(mycharm, owner): def test_consumer_events_failures(mycharm, evt_suffix, revision): ctx = Context(mycharm, meta={"name": "local"}) secret = Secret( - {"a": "b"}, - {"a": "c"}, + tracked_content={"a": "b"}, + latest_content={"a": "c"}, ) kwargs = {"secret": secret} if revision is not None: