From d64d78624fc0e478c7c12c6fd7bf26d51517684c Mon Sep 17 00:00:00 2001 From: James Garner Date: Thu, 10 Oct 2024 16:43:49 +1300 Subject: [PATCH] feat: add a manually updated collection of excluded facades These are facades that python-libjuju does not yet support. They should not be included in client_facades. Update validate test to reflect this. --- juju/client/connection.py | 8 +++++++- tests/validate/test_facades.py | 3 +++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/juju/client/connection.py b/juju/client/connection.py index c8c55cf6..a63031f1 100644 --- a/juju/client/connection.py +++ b/juju/client/connection.py @@ -9,6 +9,7 @@ import weakref from http.client import HTTPSConnection from dateutil.parser import parse +from typing import Dict, List import macaroonbakery.bakery as bakery import macaroonbakery.httpbakery as httpbakery @@ -20,7 +21,12 @@ log = logging.getLogger('juju.client.connection') +# Manual list of facades present in schemas + codegen which python-libjuju does not yet support +excluded_facades: Dict[str, List[int]] = { + 'Charms': [7], +} # Please keep in alphabetical order +# in future this will likely be generated automatically (perhaps at runtime) client_facades = { 'Action': {'versions': [7]}, 'ActionPruner': {'versions': [1]}, @@ -51,7 +57,7 @@ 'CAASUnitProvisioner': {'versions': [2]}, 'CharmDownloader': {'versions': [1]}, 'CharmRevisionUpdater': {'versions': [2]}, - 'Charms': {'versions': [6, 7]}, + 'Charms': {'versions': [6]}, 'Cleaner': {'versions': [2]}, 'Client': {'versions': [6, 7]}, 'Cloud': {'versions': [7]}, diff --git a/tests/validate/test_facades.py b/tests/validate/test_facades.py index 831473d3..2b0ada18 100644 --- a/tests/validate/test_facades.py +++ b/tests/validate/test_facades.py @@ -62,11 +62,14 @@ def make_client_facades_from_generated_code(project_root: Path) -> ClientFacades first, *rest = facades_by_version.values() sorted_facade_names: list[str] = sorted(first.union(*rest)) + excluded_facades = connection.excluded_facades client_facades: ClientFacades = {} # {facade_name: {'versions': [1, 2, 3, ...]}, ...} for name in sorted_facade_names: versions: List[int] = [] for version, facades in facades_by_version.items(): + if version in excluded_facades.get(name, []): + continue if name in facades: versions.append(version) client_facades[name] = {'versions': versions}