Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
PietroPasotti committed Nov 25, 2024
1 parent e37749a commit afff9aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
from charms.tempo_coordinator_k8s.v0.tracing import TracingEndpointRequirer
from ops.framework import StoredState
from ops.main import main
from ops.model import ActiveStatus, BlockedStatus, MaintenanceStatus, OpenedPort, Port
from ops.model import ActiveStatus, BlockedStatus, MaintenanceStatus, Port

from ops.pebble import (
APIError,
Expand Down Expand Up @@ -1280,7 +1280,9 @@ def _get_admin_password(self) -> str:

return self._stored.admin_password # type: ignore

def _poll_container(self, func: Callable[[], bool], timeout: float = 2.0, delay: float = 0.1) -> bool:
def _poll_container(
self, func: Callable[[], bool], timeout: float = 2.0, delay: float = 0.1
) -> bool:
"""Try to poll the container to work around Container.is_connect() being point-in-time.
Args:
Expand Down
22 changes: 10 additions & 12 deletions tests/scenario/test_datasources.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def test_datasource_sharing(ctx):
"remote_host/1": "juju_foo_bar_baz_1",
}


def test_datasource_get():
# GIVEN a datasource relation with two remote units
local_ds_uids = {
Expand All @@ -58,28 +59,25 @@ def test_datasource_get():
{"model": "foo", "model_uuid": "bar", "application": "baz", "type": "tempo"}
)
},
remote_app_data={
"datasource_uids": json.dumps(local_ds_uids)
}
)
state = State(
leader=True, relations={datasource}
remote_app_data={"datasource_uids": json.dumps(local_ds_uids)},
)
state = State(leader=True, relations={datasource})

# WHEN relation-changed fires for a datasource relation
class MyProviderCharm(CharmBase):
META={"name":"edgar",
"provides":{"grafana-source": {"interface": "grafana_datasource"}}}
META = {
"name": "edgar",
"provides": {"grafana-source": {"interface": "grafana_datasource"}},
}

def __init__(self, framework: Framework):
super().__init__(framework)
self.source_provider = GrafanaSourceProvider(self, "tempo",
source_url="somehost",
source_port="80")
self.source_provider = GrafanaSourceProvider(
self, "tempo", source_url="somehost", source_port="80"
)

ctx = Context(MyProviderCharm, MyProviderCharm.META)
with ctx(ctx.on.relation_changed(datasource), state) as mgr:
charm = mgr.charm
# THEN we can see our datasource uids via the provider
assert list(charm.source_provider.get_source_uids().values())[0] == local_ds_uids

0 comments on commit afff9aa

Please sign in to comment.