@mock.patch('builtins.input', side_effect=['1', '1', '', KeyboardInterrupt])
@mock.patch('tethys_apps.cli.install_commands.get_setting_type', return_value='persistent')
@mock.patch('tethys_apps.cli.install_commands.get_service_from_id', side_effect=ValueError)
@mock.patch('tethys_apps.cli.install_commands.get_service_from_name', side_effect=[False, {'service_type': 'st', 'linkParam': 'lp'}])
@mock.patch('tethys_apps.cli.install_commands.exit')
@mock.patch('tethys_apps.cli.install_commands.services_list_command')
@mock.patch('tethys_apps.cli.install_commands.get_app_settings')
@mock.patch('tethys_apps.cli.install_commands.link_service_to_app_setting')
@mock.patch('tethys_apps.cli.cli_colors.pretty_output')
def test_interactive_service_setting_all(self, mock_pretty_output, mock_lstas, mock_get_settings, mock_slc, mock_exit, ____, ___, __, _):
    mock_ss = mock.MagicMock()
    del mock_ss.value
    mock_ss.name = 'mock_ss'
    mock_ss.save.side_effect = [ValidationError('error'), mock.DEFAULT]
    mock_get_settings.return_value = {'unlinked_settings': [mock_ss, mock_ss, mock_ss, mock_ss]}
    mock_s = mock.MagicMock()
    mock_slc.side_effect = [[[]], [[mock_s]], [[mock_s]], [[mock_s]]]
    mock_exit.side_effect = SystemExit
    self.assertRaises(SystemExit, install_commands.run_interactive_services, 'foo')
    po_call_args = mock_pretty_output().__enter__().write.call_args_list
    self.assertIn('Configuring mock_ss', po_call_args[2][0][0])
    self.assertIn('Type', po_call_args[3][0][0])
    self.assertIn('No compatible services found.', po_call_args[4][0][0])
    self.assertIn('Enter the service ID/Name', po_call_args[7][0][0])
    self.assertIn('Incorrect service ID/Name.', po_call_args[8][0][0])
    self.assertIn('Enter the service ID/Name', po_call_args[9][0][0])
    self.assertIn(f'Skipping setup of {mock_ss.name}', po_call_args[13][0][0])
    self.assertEqual('\nInstall Command cancelled.', po_call_args[17][0][0])
    mock_lstas.assert_called_with('st', '1', 'foo', 'lp', 'mock_ss')
    mock_exit.assert_called_with(0)
@mock.patch('builtins.input', side_effect=['1', '1', , KeyboardInterrupt])
@mock.patch('tethys_apps.cli.install_commands.get_setting_type', return_value='persistent')
@mock.patch('tethys_apps.cli.install_commands.get_service_from_id', side_effect=ValueError)
@mock.patch('tethys_apps.cli.install_commands.get_service_from_name', side_effect=[False, {'service_type': 'st', 'linkParam': 'lp'}])
@mock.patch('tethys_apps.cli.install_commands.exit')
@mock.patch('tethys_apps.cli.install_commands.services_list_command')
@mock.patch('tethys_apps.cli.install_commands.get_app_settings')
@mock.patch('tethys_apps.cli.install_commands.link_service_to_app_setting')
@mock.patch('tethys_apps.cli.cli_colors.pretty_output')
def test_interactive_service_setting_all(self, mock_pretty_output, mock_lstas, mock_get_settings, mock_slc, mock_exit, ____, ___, __, _):
    mock_ss = mock.MagicMock()
    del mock_ss.value
    mock_ss.name = 'mock_ss'
    mock_ss.save.side_effect = [ValidationError('error'), mock.DEFAULT]
    mock_get_settings.return_value = {'unlinked_settings': [mock_ss, mock_ss, mock_ss, mock_ss]}
    mock_s = mock.MagicMock()
    mock_slc.side_effect = [[[]], [[mock_s]], [[mock_s]], [[mock_s]]]
    mock_exit.side_effect = SystemExit
    self.assertRaises(SystemExit, install_commands.run_interactive_services, 'foo')
    po_call_args = mock_pretty_output().__enter__().write.call_args_list
    self.assertIn('Configuring mock_ss', po_call_args[2][0][0])
    self.assertIn('Type', po_call_args[3][0][0])
    self.assertIn('No compatible services found.', po_call_args[4][0][0])
    self.assertIn('Enter the service ID/Name', po_call_args[7][0][0])
    self.assertIn('Incorrect service ID/Name.', po_call_args[8][0][0])
    self.assertIn('Enter the service ID/Name', po_call_args[9][0][0])
    self.assertIn(f'Skipping setup of {mock_ss.name}', po_call_args[13][0][0])
    self.assertEqual('\nInstall Command cancelled.', po_call_args[17][0][0])
    mock_lstas.assert_called_with('st', '1', 'foo', 'lp', 'mock_ss')
    mock_exit.assert_called_with(0)