def test_main_fails_for_missing_awscli(mocker, stack, arguments): arguments.extend(['awsie', stack]) mocker.patch.object(cli, 'create_session') subprocess = mocker.patch.object(cli, 'subprocess') subprocess.call.side_effect = OSError() with pytest.raises(SystemExit): cli.main()
def test_main_fails_for_missing_replacement(mocker, stack): arguments = ['awsie', stack, 'testcf:DeploymentBucket:'] mocker.patch.object(sys, 'argv', arguments) get_resource_ids = mocker.patch.object(cli, 'get_resource_ids') mocker.patch.object(cli, 'create_session') get_resource_ids.return_value = {} with pytest.raises(SystemExit): cli.main()
def test_main_replaces_and_calls_aws(mocker, stack, sysexit, arguments): arguments.extend( ['awsie', stack, 'testcf:DeploymentBucket:', 'test2', 'test3']) get_resource_ids = mocker.patch.object(cli, 'get_resource_ids') mocker.patch.object(cli, 'create_session') subprocess = mocker.patch.object(cli, 'subprocess') get_resource_ids.return_value = {'DeploymentBucket': '1'} cli.main() subprocess.call.assert_called_with(['aws', 'test1', 'test2', 'test3']) sysexit.assert_called_with(subprocess.call.return_value)