예제 #1
0
def test_write_suite_environment(fixture_get_platform, monkeypatch):
    """Test suite environment is correctly written in jobscript"""
    # set some suite environment conditions
    monkeypatch.setattr(cylc.flow.job_file, "get_remote_suite_work_dir",
                        lambda a, b: "work/dir")
    monkeypatch.setenv('CYLC_SUITE_DEF_PATH', 'cylc/suite/def/path')
    cylc.flow.flags.debug = True
    cylc.flow.flags.verbose = True
    suite_env = {'CYLC_UTC': 'True', 'CYLC_CYCLING_MODE': 'integer'}
    job_file_writer = JobFileWriter()
    job_file_writer.set_suite_env(suite_env)
    # suite env not correctly setting...check this
    expected = ('\n\ncylc__job__inst__cylc_env() {\n    # CYLC SUITE '
                'ENVIRONMENT:\n    export CYLC_CYCLING_MODE="integer"\n  '
                '  export CYLC_UTC="True"\n    export TZ="UTC"\n\n   '
                ' export CYLC_SUITE_RUN_DIR="cylc-run/farm_noises"\n   '
                ' export CYLC_SUITE_WORK_DIR_ROOT="work/dir"\n   '
                ' export CYLC_SUITE_DEF_PATH="remote/suite/dir"\n    expor'
                't CYLC_SUITE_DEF_PATH_ON_SUITE_HOST="cylc/suite/def/path"'
                '\n    export CYLC_SUITE_UUID="neigh"')
    job_conf = {
        "platform": fixture_get_platform({
            "host": "localhost",
            "owner": "me",
        }),
        "suite_name": "farm_noises",
        "remote_suite_d": "remote/suite/dir",
        "uuid_str": "neigh"
    }
    rund = "cylc-run/farm_noises"
    with io.StringIO() as fake_file:
        job_file_writer._write_suite_environment(fake_file, job_conf, rund)
        assert (fake_file.getvalue() == expected)
예제 #2
0
def test_write_suite_environment_no_remote_suite_d(fixture_get_platform,
                                                   monkeypatch):
    """Test suite environment is correctly written in jobscript"""

    monkeypatch.setattr(cylc.flow.job_file, "get_remote_suite_work_dir",
                        lambda a, b: "work/dir")
    cylc.flow.flags.debug = True
    cylc.flow.flags.verbose = True
    suite_env = {'CYLC_UTC': 'True', 'CYLC_CYCLING_MODE': 'integer'}
    job_file_writer = JobFileWriter()
    job_file_writer.set_suite_env(suite_env)
    expected = ('\n\ncylc__job__inst__cylc_env() {\n    # CYLC SUITE '
                'ENVIRONMENT:\n    export CYLC_CYCLING_MODE="integer"\n    '
                'export CYLC_UTC="True"\n    export TZ="UTC"\n\n    export '
                'CYLC_SUITE_RUN_DIR="cylc-run/farm_noises"\n    '
                'export CYLC_SUITE_WORK_DIR_ROOT="work/dir"\n   '
                ' export CYLC_SUITE_UUID="neigh"')
    job_conf = {
        "platform": fixture_get_platform({
            "host": "localhost",
        }),
        "suite_name": "farm_noises",
        "uuid_str": "neigh",
        "remote_suite_d": ""
    }
    rund = "cylc-run/farm_noises"
    with io.StringIO() as fake_file:
        job_file_writer._write_suite_environment(fake_file, job_conf, rund)
        result = fake_file.getvalue()
        assert result == expected