@@ -42,22 +42,25 @@ def test_login_execute(mocker: MockerFixture, _instance): # type: ignore[no-unt
42
42
m .assert_called_once_with ("instance-1" )
43
43
44
44
45
- @pytest .mark .skip (reason = "needs rewrite after switch to delegated" )
46
45
@pytest .mark .parametrize (
47
46
"config_instance" ,
48
47
["command_driver_delegated_managed_section_data" ], # noqa: PT007
49
48
indirect = True ,
50
49
)
51
- def test_execute_raises_when_not_created (caplog , _instance ): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019, D103
50
+ def test_login_execute_instance_creation (mocker : MockerFixture , _instance ): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019, D103
51
+ _instance ._config .command_args = {"host" : "instance-1" }
52
52
_instance ._config .state .change_state ("created" , False ) # noqa: FBT003
53
53
54
- with pytest .raises (SystemExit ) as e :
55
- _instance .execute ()
56
-
57
- assert e .value .code == 1
54
+ mocker .patch ("molecule.command.login.Login._get_login" )
55
+ patched_execute_subcommand = mocker .patch ("molecule.command.base.execute_subcommand" )
56
+ patched_execute_subcommand .side_effect = lambda _config , _ : _config .state .change_state (
57
+ key = "created" ,
58
+ value = True ,
59
+ )
60
+ _instance .execute ()
58
61
59
- msg = "Instances not created. Please create instances first."
60
- assert msg in caplog . text
62
+ patched_execute_subcommand . assert_called_once_with ( _instance . _config , " create" )
63
+ assert _instance . _config . state . created
61
64
62
65
63
66
def test_get_hostname_does_not_match (caplog , _instance ): # type: ignore[no-untyped-def] # noqa: ANN001, ANN201, PT019, D103
0 commit comments