11import unittest
2+ from unittest .mock import patch , PropertyMock
23
34import mock
45
6+ import asyncio
57import asynctest
8+ import datetime
69
710from juju .client .jujudata import FileJujuData
811from juju .model import Model
@@ -264,6 +267,7 @@ async def test_with_posargs(self, mock_connect, mock_connect_model, _):
264267 max_frame_size = 'max_frame_size' )
265268
266269
270+ @patch ('juju.model.timedelta' , new = lambda * a , ** kw : datetime .timedelta (0 ))
267271class TestModelWaitForIdle (asynctest .TestCase ):
268272 async def test_no_args (self ):
269273 m = Model ()
@@ -273,10 +277,9 @@ async def test_no_args(self):
273277
274278 async def test_timeout (self ):
275279 m = Model ()
276- import asyncio
277280 with self .assertRaises (asyncio .TimeoutError ) as cm :
278281 # no apps so should timeout after timeout period
279- await m .wait_for_idle (apps = ["nonexisting_app" ], timeout = 1 , idle_period = 0 )
282+ await m .wait_for_idle (apps = ["nonexisting_app" ])
280283 self .assertEqual (str (cm .exception ), "Timed out waiting for model:\n nonexisting_app (missing)" )
281284
282285 async def test_wait_for_active_status (self ):
@@ -293,19 +296,17 @@ async def test_wait_for_active_status(self):
293296 )],
294297 )}
295298
296- from unittest .mock import patch , PropertyMock
297299 with patch .object (Model , 'applications' , new_callable = PropertyMock ) as mock_apps :
298300 mock_apps .return_value = apps
299301 m = Model ()
300302
301303 # pass "active" via `status` (str)
302- await m .wait_for_idle (apps = ["dummy_app" ], status = "active" , timeout = 5 , idle_period = 0 )
304+ await m .wait_for_idle (apps = ["dummy_app" ], status = "active" )
303305
304306 # pass "active" via `wait_for_active` (bool; deprecated)
305- await m .wait_for_idle (apps = ["dummy_app" ], wait_for_active = True , timeout = 5 , idle_period = 0 )
307+ await m .wait_for_idle (apps = ["dummy_app" ], wait_for_active = True )
306308
307309 # use both `status` and `wait_for_active` - `wait_for_active` takes precedence
308- await m .wait_for_idle (apps = ["dummy_app" ], wait_for_active = True , status = "doesn't matter" , timeout = 5 ,
309- idle_period = 0 )
310+ await m .wait_for_idle (apps = ["dummy_app" ], wait_for_active = True , status = "doesn't matter" )
310311
311312 mock_apps .assert_called ()
0 commit comments