def test_gaussian_td_settings(tmpdir, water, use_tda, theory):
    """
    Test for the correct parsing of any td_settings included in the qcoptions schema.
    """
    with tmpdir.as_cwd():
        task = qcel.models.AtomicInput(
            molecule=water.to_qcschema(),
            driver="energy",
            model={
                "method": "cam-b3lyp",
                "basis": "6-31G*"
            },
            keywords={
                "tdscf_states": 10,
                "tdscf_tda": use_tda
            },
        )
        gaussian_harness = GaussianHarness()
        config = qcng.config.get_config(task_config={"ncores": 1, "memory": 1})
        job_inputs = gaussian_harness.build_input(task, config)
        job_script = job_inputs["infiles"]["gaussian.com"]
        if use_tda:
            theory = "TDA"
        else:
            theory = "TD"
        assert job_script.find(f"{theory}=(nstates=10)") != -1
def test_gaussian_nbo_input_file(tmpdir, water):
    """Make sure we can build a file which will run a nbo calculation when complete."""
    with tmpdir.as_cwd():
        # now make an atomic input for the harness
        task = qcel.models.AtomicInput(
            molecule=water.to_qcschema(),
            driver="energy",
            model={
                "method": "b3lyp-d3bj",
                "basis": "6-311G"
            },
            keywords={"scf_properties": ["wiberg_lowdin_indices"]},
        )
        # we need the harness as this will render the template
        gaussian_harness = GaussianHarness()
        config = qcng.config.get_config(task_config={"ncores": 1, "memory": 1})
        job_inputs = gaussian_harness.build_input(task, config)
        # make sure the job file matches or expected reference
        with open(get_data("gaussian_nbo_example.com")) as g_out:
            assert g_out.read() == job_inputs["infiles"]["gaussian.com"]
def test_build_input(tmpdir, driver, result, acetone):
    """
    Build a gaussian input file for the given input model.
    """
    with tmpdir.as_cwd():
        # build the atomic model
        qc_spec = qcel.models.common_models.Model(method="pbe", basis="6-31G")
        # build a job for s specific driver
        qc_task = qcel.models.AtomicInput(molecule=acetone.to_qcschema(),
                                          driver=driver,
                                          model=qc_spec)
        g = GaussianHarness()
        local_options = qcng.config.TaskConfig(ncores=10,
                                               memory=10,
                                               nnodes=1,
                                               retries=1)
        input_data = g.build_input(input_model=qc_task, config=local_options)
        file_input = input_data["infiles"]["gaussian.com"]
        # now make sure the driver conversion is in the file input
        assert result in file_input
        # make sure we can write the file with no issues
        with open("gaussian.com", "w") as com:
            com.write(file_input)