canonical / data-platform-libs

A collection of charm libraries curated by the Data Platform Team
https://charmhub.io/data-platform-libs
Apache License 2.0
9 stars 9 forks source link

fix: add missing dependency (pylibjuju) #120

Open tonyandrewmeyer opened 7 months ago

tonyandrewmeyer commented 7 months ago

The tests use importlib.metadata to get the installed version of pylibjuju (tests/conftest.py):

    if juju_version := os.environ.get("LIBJUJU_VERSION_SPECIFIER"):
        juju_version.replace("==", "")
        juju_version = juju_version[2:].split(".")[0]
    else:
        juju_version = version("juju")

However, pylibjuju is not installed as part of the requirements. This means that all tests fail with an error like:

ERROR tests/unit/test_data_interfaces.py::TestDatabaseProvides::test_database_requested_event - importlib.metadata.PackageNotFoundError: No package metadata was found for juju

This is fixed by installing pylibjuju. Alternatively, the version("juju") could be wrapped in a try/except, and you could fall back to a hard-coded version?

Note that there are still some other tests that fail for unrelated reasons (see canonical/operator#1088).