From ec9233bb6efd4fdc2649088b8cd8e13170c48169 Mon Sep 17 00:00:00 2001 From: Dima Tisnek Date: Tue, 15 Oct 2024 17:30:14 +0900 Subject: [PATCH] chore: exact and at least units are exclusive --- juju/model.py | 2 +- tests/unit/test_wait_for_idle.py | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/juju/model.py b/juju/model.py index 767710ff..00e94837 100644 --- a/juju/model.py +++ b/juju/model.py @@ -3149,7 +3149,7 @@ async def _check_idle( ready_units.append(unit) - if len(ready_units) < _wait_for_units: + if wait_for_exact_units is None and len(ready_units) < _wait_for_units: logging.info("Waiting for app %r units %s/%s", app_name, len(ready_units), _wait_for_units) return False diff --git a/tests/unit/test_wait_for_idle.py b/tests/unit/test_wait_for_idle.py index 49b8bb3f..c7e14638 100644 --- a/tests/unit/test_wait_for_idle.py +++ b/tests/unit/test_wait_for_idle.py @@ -82,6 +82,19 @@ async def test_wrong_exact_count(full_status_response: dict, kwargs: dict, wrong assert not idle and not legacy +async def test_exact_count_precedence(full_status_response: dict, kwargs: dict): + app = full_status_response["response"]["applications"]["hexanator"] + app["units"]["hexanator/1"] = copy.deepcopy(app["units"]["hexanator/0"]) + + kwargs["apps"] = ["hexanator"] + kwargs["wait_for_exact_units"] = 2 + kwargs["wait_for_at_least_units"] = 9 + kwargs["_wait_for_units"] = 9 + + idle, legacy = await model_fake(full_status_response).check_both(**kwargs) + assert idle and legacy + + async def test_ready_unit_count(full_status_response: dict, kwargs: dict): app = full_status_response["response"]["applications"]["hexanator"] app["units"]["hexanator/1"] = copy.deepcopy(app["units"]["hexanator/0"])