Skip to content

Commit

Permalink
Go back to making only one content positional.
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyandrewmeyer committed Aug 7, 2024
1 parent 09e7599 commit c26e059
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 14 deletions.
2 changes: 1 addition & 1 deletion scenario/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions tests/test_context_on.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -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})
Expand Down
17 changes: 8 additions & 9 deletions tests/test_e2e/test_secrets.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import datetime
import warnings

import pytest
from ops.charm import CharmBase
Expand Down Expand Up @@ -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(),
Expand All @@ -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(
Expand All @@ -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):
Expand All @@ -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:
Expand Down

0 comments on commit c26e059

Please sign in to comment.