In some integration tests, charm authors find themselves writing helpers to fetch and assert on the status of snap services. An example would be https://github.com/canonical/opentelemetry-collector-operator/blob/9fa23d2d2dcd14e21966c3f3b784492cc9ae969d/tests/integration/helpers.py#L49-L60
I wonder if it makes sense to add two helper methods for checking the status of a snap or pebble service.
The first helper would have a signature roughly like this:
def check_snap_status(
self,
app: str,
snap: str,
unit_num: int = 0,
) -> str:
Its usage would be something like:
import jubilant
...
assert jubilant.check_snap_status("otelcol", "opentelemetry-collector", 1) == "active"
Along the same lines, the second helper would have a signature roughly like this:
def check_snap_status(
self,
app: str,
pebble_service: str,
unit_num: int = 0,
containre_name: str,
) -> str:
Its usage would be something like:
import jubilant
...
assert jubilant.check_snap_status("otelcol", "otelcol", 1, "otelcol") == "active"
I'd be happy to contribute this if you think it'd make a valuable addition. My question is, since _juju.py is merely a wrapper around the Juju CLI, where should a helper like this go? In a dedicated _helpers.py file or should it be added to the existing _test_helpers.py file?
In some integration tests, charm authors find themselves writing helpers to fetch and assert on the status of snap services. An example would be https://github.com/canonical/opentelemetry-collector-operator/blob/9fa23d2d2dcd14e21966c3f3b784492cc9ae969d/tests/integration/helpers.py#L49-L60
I wonder if it makes sense to add two helper methods for checking the status of a snap or pebble service.
The first helper would have a signature roughly like this:
Its usage would be something like:
Along the same lines, the second helper would have a signature roughly like this:
Its usage would be something like:
I'd be happy to contribute this if you think it'd make a valuable addition. My question is, since
_juju.pyis merely a wrapper around the Juju CLI, where should a helper like this go? In a dedicated_helpers.pyfile or should it be added to the existing_test_helpers.pyfile?