@@ -208,7 +208,7 @@ def test_remove_running_profile(self):
208208@pytest .mark .slow
209209@pytest .mark .trylast
210210class TestInstanceLifecycle :
211- def test_start_stop_reset (self , instance , docker_client , caplog ):
211+ def test_start_stop_reset (self , instance , docker_client , caplog , monkeypatch ):
212212 caplog .set_level (logging .DEBUG )
213213
214214 def get_volume (volume_name ):
@@ -260,6 +260,20 @@ def assert_status_down():
260260 assert result .exit_code == 0
261261 assert_status_up ()
262262
263+ # test the warning message of image not the latest is not raised
264+ assert "Warning!" not in result .output .strip ()
265+
266+ # Then by monkeypatching the image_is_latest function, we can test that
267+ # the warning message is raised
268+ def image_is_latest (docker_client , image_name ):
269+ return False
270+
271+ monkeypatch .setattr ("aiidalab_launch.util.image_is_latest" , image_is_latest )
272+ result : Result = runner .invoke (
273+ cli .cli , ["start" , "--no-browser" , "--no-pull" , "--wait=300" ]
274+ )
275+ assert "Warning!" in result .output .strip ()
276+
263277 # Restart instance.
264278 # TODO: This test is currently disabled, because it is too flaky. For
265279 # a currently unknown reason, the docker client will not be able to
0 commit comments