@patch('ooinstall.openshift_ansible.run_main_playbook')
    @patch('ooinstall.openshift_ansible.load_system_facts')
    def test_inventory_write(self, load_facts_mock, run_playbook_mock):

        # Add an ssh user so we can verify it makes it to the inventory file:
        merged_config = "%s\n%s" % (SAMPLE_CONFIG % 'openshift-enterprise',
            "ansible_ssh_user: bob")
        load_facts_mock.return_value = (MOCK_FACTS, 0)
        run_playbook_mock.return_value = 0

        config_file = self.write_config(os.path.join(self.work_dir,
            'ooinstall.conf'), merged_config)

        self.cli_args.extend(["-c", config_file, "install"])
        result = self.runner.invoke(cli.cli, self.cli_args)
        self.assert_result(result, 0)

        # Check the inventory file looks as we would expect:
        inventory = ConfigParser.ConfigParser(allow_no_value=True)
        inventory.read(os.path.join(self.work_dir, 'hosts'))
        self.assertEquals('bob',
            inventory.get('OSEv3:vars', 'ansible_ssh_user'))
        self.assertEquals('openshift-enterprise',
            inventory.get('OSEv3:vars', 'deployment_type'))

        # Check the masters:
        self.assertEquals(1, len(inventory.items('masters')))
        self.assertEquals(3, len(inventory.items('nodes')))

        for item in inventory.items('masters'):
            # ansible host lines do NOT parse nicely:
            master_line = item[0]
            if item[1] is not None:
                master_line = "%s=%s" % (master_line, item[1])
            self.assertTrue('openshift_ip' in master_line)
            self.assertTrue('openshift_public_ip' in master_line)
            self.assertTrue('openshift_hostname' in master_line)
            self.assertTrue('openshift_public_hostname' in master_line)
dataset/ETHPy150Open openshift/openshift-ansible/utils/test/cli_installer_tests.py/UnattendedCliTests.test_inventory_write/original