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)
def test_version(): """Test version command""" with arguments('esmvaltool', 'version'): run() with arguments('esmvaltool', 'version', '--extra_parameter=asterisk'): with pytest.raises(FireExit): run()
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()
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()
def test_run_with_synda_download(): with arguments('esmvaltool', 'run', 'recipe.yml', '--synda_download=True'): run()
def test_run_with_max_datasets(): with arguments('esmvaltool', 'run', 'recipe.yml', '--max_datasets=2'): run()
def test_run_with_max_years(): with arguments('esmvaltool', 'run', 'recipe.yml', '--config_file=config.yml', '--max_years=2'): run()
def test_tun_with_config(): with arguments('esmvaltool', 'run', 'recipe.yml', '--config_file', 'config.yml'): run()
def test_run(): """Test version command""" with arguments('esmvaltool', 'run', 'recipe.yml'): run()
def test_run_with_diagnostics(): with arguments('esmvaltool', 'run', 'recipe.yml', '--diagnostics=[badt]'): run()
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()
def test_get_config_user(): """Test version command""" with arguments('esmvaltool', 'config', 'get_config_user'): run()
def test_recipes_list_do_not_admit_parameters(): """Test version command""" with arguments('esmvaltool', 'recipes', 'list', 'parameter'): with pytest.raises(FireExit): run()
def test_recipes_list(): """Test version command""" with arguments('esmvaltool', 'recipes', 'list'): run()
def test_run_fails_with_other_params(): with arguments('esmvaltool', 'run', 'recipe.yml', '--extra_param=dfa'): with pytest.raises(SystemExit): run()
def test_run_with_check_level(): with arguments('esmvaltool', 'run', 'recipe.yml', '--check_level=default'): run()
def test_run_with_skip_nonexistent(): with arguments('esmvaltool', 'run', 'recipe.yml', '--skip_nonexistent=True'): run()
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()