Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Register start handler also when config is invalid #37

Merged
merged 3 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def __init__(self, *args):
args: Arguments passed to the CharmBase parent constructor.
"""
super().__init__(*args)
self.framework.observe(self.on.start, self._on_start)
try:
self._charm_state = CharmState.from_charm(charm=self)
self._saml_integrator = SamlIntegrator(charm_state=self._charm_state)
Expand All @@ -38,7 +39,6 @@ def __init__(self, *args):
self.saml = saml.SamlProvides(self)
self.framework.observe(self.on[RELATION_NAME].relation_created, self._on_relation_created)
self.framework.observe(self.on.config_changed, self._on_config_changed)
self.framework.observe(self.on.start, self._on_start)
self.framework.observe(self.on.update_status, self._on_update_status)

def _on_start(self, _) -> None:
Expand Down
8 changes: 3 additions & 5 deletions tests/integration/test_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,16 @@ async def test_relation(ops_test: OpsTest, app: ops.Application, any_charm: ops.

Assume that the charm has already been built and is running.
"""
relation_name = f"{app.name}:saml"
await ops_test.model.add_relation(any_charm.name, relation_name)
await app.set_config( # type: ignore[attr-defined]
{
"entity_id": "https://login.staging.ubuntu.com",
"fingerprint": "",
"metadata_url": "https://login.staging.ubuntu.com/saml/metadata",
}
)
status_name = ops.ActiveStatus.name # type: ignore[has-type]
assert ops_test.model
await ops_test.model.wait_for_idle(status=status_name, raise_on_error=True)
assert app.units[0].workload_status == status_name # type: ignore
relation_name = f"{app.name}:saml"
await ops_test.model.add_relation(any_charm.name, relation_name)
status_name = ops.ActiveStatus.name # type: ignore[has-type]
await ops_test.model.wait_for_idle(status=status_name, raise_on_error=True)
assert app.units[0].workload_status == status_name # type: ignore