File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,13 +26,18 @@ def project_root(pytestconfig: pytest.Config) -> Path:
2626@pytest .fixture
2727def generated_code_facades (project_root : Path ) -> ClientFacades :
2828 """Return a client_facades dictionary from generated code under project_root.
29+
30+ Iterates through all the generated files matching juju/client/_client*.py,
31+ extracting facade types (those that have .name and .version properties).
32+ Excludes facades in juju.client.connection.excluded_facades, as these are
33+ manually marked as incompatible with the current version of python-libjuju.
2934 """
3035 facades : Dict [str , List [int ]] = defaultdict (list )
31- for file in ( project_root / 'juju' / 'client' ) .glob ('_client[0-9] *.py' ):
36+ for file in project_root .glob ('juju/client/ _client*.py' ):
3237 module = importlib .import_module (f'juju.client.{ file .stem } ' )
3338 for cls_name in dir (module ):
3439 cls = getattr (module , cls_name )
35- try :
40+ try : # duck typing check for facade types
3641 cls .name
3742 cls .version
3843 except AttributeError :
@@ -44,6 +49,10 @@ def generated_code_facades(project_root: Path) -> ClientFacades:
4449
4550
4651def test_client_facades (project_root : Path , generated_code_facades : ClientFacades ) -> None :
52+ """Ensure that juju.client.connection.client_facades matches expected facades.
53+
54+ See generated_code_facades for how expected facades are computed.
55+ """
4756 assert {
4857 k : v ['versions' ] for k , v in client_facades .items ()
4958 } == {
You can’t perform that action at this time.
0 commit comments