def test_processconfigsresource5():
    """
    Test for missing resource parameter exception.
    """

    parameters = {
        "debug": False,
        "disconnect": False,
        "executable": "",
        "executableargs": [],
        "hosts": "",
        "job": "",
        "jobname": "",
        "log": "",
        "recover": "",
        "resource": "",
        "replicates": "",
        "verbose": False
    }

    jobdata = {
        "LongbowJob": {
            "account": "",
            "accountflag": "",
            "cores": "",
            "corespernode": "",
            "download-exclude": "",
            "download-include": "",
            "email-address": "",
            "email-flags": "",
            "executable": "",
            "executableargs": "",
            "polling-frequency": "",
            "handler": "",
            "host": "",
            "localworkdir": "",
            "lsf-cluster": "",
            "modules": "",
            "maxtime": "",
            "memory": "",
            "scripts": "",
            "staging-frequency": "",
            "sge-peflag": "",
            "sge-peoverride": "",
            "port": "",
            "queue": "",
            "remoteworkdir": "",
            "resource": "host10",
            "replicates": "",
            "scheduler": "",
            "user": "",
            "upload-exclude": "",
            "upload-include": ""
        }
    }

    hostsections = ["host1", "host2", "host3"]

    with pytest.raises(ex.ConfigurationError):

        _processconfigsresource(parameters, jobdata, hostsections)
def test_processconfigsresource1():
    """
    Simple test with close to defaults.
    """

    parameters = {
        "debug": False,
        "disconnect": False,
        "executable": "",
        "executableargs": [],
        "hosts": "",
        "job": "",
        "jobname": "",
        "log": "",
        "recover": "",
        "resource": "",
        "replicates": "",
        "verbose": False
    }

    jobdata = {
        "LongbowJob": {
            "account": "",
            "accountflag": "",
            "cores": "",
            "corespernode": "",
            "download-exclude": "",
            "download-include": "",
            "email-address": "",
            "email-flags": "",
            "executable": "",
            "executableargs": "",
            "polling-frequency": "",
            "handler": "",
            "host": "",
            "localworkdir": "",
            "lsf-cluster": "",
            "modules": "",
            "maxtime": "",
            "memory": "",
            "scripts": "",
            "staging-frequency": "",
            "stdout": "",
            "stderr": "",
            "sge-peflag": "",
            "sge-peoverride": "",
            "port": "",
            "queue": "",
            "remoteworkdir": "",
            "resource": "",
            "replicates": "",
            "scheduler": "",
            "user": "",
            "upload-exclude": "",
            "upload-include": ""
        }
    }

    expected = {
        "LongbowJob": {
            "account": "",
            "accountflag": "",
            "cores": "24",
            "corespernode": "24",
            "download-exclude": "",
            "download-include": "",
            "email-address": "",
            "email-flags": "",
            "env-fix": "false",
            "executable": "",
            "executableargs": "",
            "handler": "",
            "host": "",
            "localworkdir": "",
            "lsf-cluster": "",
            "modules": "",
            "maxtime": "24:00",
            "memory": "",
            "mpiprocs": "",
            "nochecks": False,
            "scripts": "",
            "slurm-gres": "",
            "staging-frequency": "300",
            "stdout": "",
            "stderr": "",
            "sge-peflag": "mpi",
            "sge-peoverride": "false",
            "polling-frequency": "300",
            "port": "22",
            "queue": "",
            "recoveryfile": "",
            "remoteworkdir": "",
            "resource": "host1",
            "replicates": "1",
            "replicate-naming": "rep",
            "scheduler": "",
            "subfile": "",
            "user": "",
            "upload-exclude": "",
            "upload-include": ""
        }
    }

    hostsections = ["host1", "host2", "host3"]

    jobs = _processconfigsresource(parameters, jobdata, hostsections)

    for item in jobs["LongbowJob"]:

        assert jobs["LongbowJob"][item] == expected["LongbowJob"][item]