Skip to content

Commit 4efa266

Browse files
committed
Fix unit test TestModelWaitForIdle::test_wait_for_active_status
1 parent 8286418 commit 4efa266

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

tests/unit/test_model.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from juju import jasyncio
1414
from juju.errors import JujuConnectionError
1515

16+
from .. import base
17+
1618

1719
def _make_delta(entity, type_, data=None):
1820
from juju.client.client import Delta
@@ -297,7 +299,7 @@ async def test_timeout(self):
297299
async def test_wait_for_active_status(self):
298300
# create a custom apps mock
299301
from types import SimpleNamespace
300-
apps = {"dummy_app": SimpleNamespace(
302+
app = SimpleNamespace(
301303
status="active",
302304
units=[SimpleNamespace(
303305
name="mockunit/0",
@@ -306,7 +308,14 @@ async def test_wait_for_active_status(self):
306308
machine=None,
307309
agent_status="idle",
308310
)],
309-
)}
311+
)
312+
# This is a small hack to act like we're getting 'unknown'
313+
# from the api (the get_status() call), which shouldn't
314+
# change the semantics of this test, as the 'unknown'
315+
# has the lowest severity (so the app's 'active' status
316+
# will overrule it)
317+
app.get_status = base.AsyncMock(return_value='unknown')
318+
apps = {"dummy_app": app}
310319

311320
with patch.object(Model, 'applications', new_callable=PropertyMock) as mock_apps:
312321
mock_apps.return_value = apps

0 commit comments

Comments
 (0)