Skip to content

Commit e800b48

Browse files
test: simplify globbing expression and add docstrings
1 parent d911ef4 commit e800b48

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

tests/validate/test_facades.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,18 @@ def project_root(pytestconfig: pytest.Config) -> Path:
2626
@pytest.fixture
2727
def 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

4651
def 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
} == {

0 commit comments

Comments
 (0)