@@ -12,18 +12,23 @@ class TestRestart:
1212 """Tests covering pycloudlib.lxd.instance.Instance.restart."""
1313
1414 @pytest .mark .parametrize ("force" , (False , True ))
15- @mock .patch ("pycloudlib.lxd.instance.LXDInstance.start" )
16- @mock .patch ("pycloudlib.lxd.instance.LXDInstance.shutdown" )
17- @mock .patch ("pycloudlib.lxd.instance.LXDInstance.wait" )
1815 @mock .patch ("pycloudlib.lxd.instance.subp" )
19- def test_restart_calls_lxc_cmd_with_force_param (
20- self , _m_subp , _m_wait , m_shutdown , m_start , force
21- ):
22- """Honor force param on shutdown."""
16+ def test_restart_calls_lxc_cmd_with_force_param (self , m_subp , force ):
17+ """Honor force param on restart."""
2318 instance = LXDInstance (name = "my_vm" )
2419 instance ._do_restart (force = force ) # pylint: disable=protected-access
25- assert [mock .call (wait = True , force = force )] == m_shutdown .call_args_list
26- assert [mock .call (wait = False )] == m_start .call_args_list
20+ if force :
21+ assert "--force" in m_subp .call_args [0 ][0 ]
22+ else :
23+ assert "--force" not in m_subp .call_args [0 ][0 ]
24+
25+ @mock .patch ("pycloudlib.lxd.instance.LXDInstance.shutdown" )
26+ @mock .patch ("pycloudlib.lxd.instance.subp" )
27+ def test_restart_does_not_shutdown (self , _m_subp , m_shutdown ):
28+ """Don't shutdown (stop) instance on restart."""
29+ instance = LXDInstance (name = "my_vm" )
30+ instance ._do_restart () # pylint: disable=protected-access
31+ assert not m_shutdown .called
2732
2833
2934class TestExecute :
0 commit comments