'Tests cli_installer.py:get_hosts_to_run_on.  That method has quite a
few subtle branches in the logic.  The goal with this method is simply
to handle all the messy stuff here and allow the main test cases to be
easily read.  The basic idea is to modify mock_facts to return a
version indicating OpenShift is already installed on particular hosts.'

def _verify_get_hosts_to_run_on(self, mock_facts, load_facts_mock, run_playbook_mock, cli_input, exp_hosts_len=None, exp_hosts_to_run_on_len=None, force=None):

    load_facts_mock.return_value = (mock_facts, 0)
    run_playbook_mock.return_value = 0
    if cli_input:
        self.cli_args.append('install')
        result = self.runner.invoke(cli.cli, self.cli_args, input=cli_input)
    else:
        config_file = self.write_config(os.path.join(self.work_dir, 'ooinstall.conf'), (SAMPLE_CONFIG % 'openshift-enterprise'))
        self.cli_args.extend(['-c', config_file, 'install'])
        if force:
            self.cli_args.append('--force')
        result = self.runner.invoke(cli.cli, self.cli_args)
        written_config = read_yaml(config_file)
        self._verify_config_hosts(written_config, exp_hosts_len)
    if ('If    you    want    to    force    reinstall' in result.output):
        self.assertEqual(result.exit_code, 1)
    else:
        self.assert_result(result, 0)
        self._verify_load_facts(load_facts_mock)
        self._verify_run_playbook(run_playbook_mock, exp_hosts_len, exp_hosts_to_run_on_len)
        hosts = run_playbook_mock.call_args[0][1]
        hosts_to_run_on = run_playbook_mock.call_args[0][2]
        self.assertEquals(exp_hosts_len, len(hosts))
        self.assertEquals(exp_hosts_to_run_on_len, len(hosts_to_run_on))
