Esempio n. 1
0
def test_diagnostic_run(tmp_path, script_file, script):

    recipe_file = tmp_path / 'recipe_test.yml'
    script_file = tmp_path / script_file
    result_file = tmp_path / 'result.yml'

    # Write script to file
    script_file.write_text(str(script))

    # Create recipe
    recipe = dedent("""
        documentation:
          description: Recipe with no data.
          authors: [andela_bouwe]

        diagnostics:
          diagnostic_name:
            scripts:
              script_name:
                script: {}
                setting_name: {}
        """.format(script_file, result_file))
    recipe_file.write_text(str(recipe))

    config_user_file = write_config_user_file(tmp_path)
    with arguments(
            'esmvaltool',
            '-c',
            config_user_file,
            str(recipe_file),
    ):
        run()

    check(result_file)
Esempio n. 2
0
def test_version():
    """Test version command"""
    with arguments('esmvaltool', 'version'):
        run()
    with arguments('esmvaltool', 'version', '--extra_parameter=asterisk'):
        with pytest.raises(FireExit):
            run()
Esempio n. 3
0
def test_get_config_user_overwrite(tmp_path):
    """Test version command"""
    config_user = tmp_path / 'config-user.yml'
    config_user.touch()
    with arguments('esmvaltool', 'config', 'get_config_user',
                   f'--path={tmp_path}', '--overwrite'):
        run()
Esempio n. 4
0
def test_recipes_get(tmp_path, monkeypatch):
    """Test version command"""
    src_recipe = tmp_path / 'recipe.yml'
    src_recipe.touch()
    tgt_dir = tmp_path / 'test'
    tgt_dir.mkdir()
    monkeypatch.chdir(tgt_dir)
    with arguments('esmvaltool', 'recipes', 'get', str(src_recipe)):
        run()
    assert (tgt_dir / 'recipe.yml').is_file()
Esempio n. 5
0
def test_run_with_synda_download():
    with arguments('esmvaltool', 'run', 'recipe.yml', '--synda_download=True'):
        run()
Esempio n. 6
0
def test_run_with_max_datasets():
    with arguments('esmvaltool', 'run', 'recipe.yml', '--max_datasets=2'):
        run()
Esempio n. 7
0
def test_run_with_max_years():
    with arguments('esmvaltool', 'run', 'recipe.yml',
                   '--config_file=config.yml', '--max_years=2'):
        run()
Esempio n. 8
0
def test_tun_with_config():
    with arguments('esmvaltool', 'run', 'recipe.yml', '--config_file',
                   'config.yml'):
        run()
Esempio n. 9
0
def test_run():
    """Test version command"""
    with arguments('esmvaltool', 'run', 'recipe.yml'):
        run()
Esempio n. 10
0
def test_run_with_diagnostics():
    with arguments('esmvaltool', 'run', 'recipe.yml', '--diagnostics=[badt]'):
        run()
Esempio n. 11
0
def test_get_config_user_path(tmp_path):
    """Test version command"""
    with arguments('esmvaltool', 'config', 'get_config_user',
                   f'--path={tmp_path}'):
        run()
    assert (tmp_path / 'config-user.yml').is_file()
Esempio n. 12
0
def test_get_config_user():
    """Test version command"""
    with arguments('esmvaltool', 'config', 'get_config_user'):
        run()
Esempio n. 13
0
def test_recipes_list_do_not_admit_parameters():
    """Test version command"""
    with arguments('esmvaltool', 'recipes', 'list', 'parameter'):
        with pytest.raises(FireExit):
            run()
Esempio n. 14
0
def test_recipes_list():
    """Test version command"""
    with arguments('esmvaltool', 'recipes', 'list'):
        run()
Esempio n. 15
0
def test_run_fails_with_other_params():
    with arguments('esmvaltool', 'run', 'recipe.yml', '--extra_param=dfa'):
        with pytest.raises(SystemExit):
            run()
Esempio n. 16
0
def test_run_with_check_level():
    with arguments('esmvaltool', 'run', 'recipe.yml', '--check_level=default'):
        run()
Esempio n. 17
0
def test_run_with_skip_nonexistent():
    with arguments('esmvaltool', 'run', 'recipe.yml',
                   '--skip_nonexistent=True'):
        run()
Esempio n. 18
0
def test_get_config_user_bad_option_fails():
    """Test version command"""
    with arguments('esmvaltool', 'config', 'get_config_user',
                   '--bad_option=path'):
        with pytest.raises(FireExit):
            run()