def test_save_skill(startdatestr, enddatestr, n_models, expected_skill_today, tmpdir):
    """Test if the skill are saved correctly and the daily average is computed"""

    # get validtime
    currentdate = datetime.strptime(startdatestr, "%Y%m%d%H%M%S")
    enddate = datetime.strptime(enddatestr, "%Y%m%d%H%M%S")
    timestep = timedelta(minutes=5)

    outdir_path = tmpdir

    while currentdate <= enddate:
        current_skill = generate_fixed_skill(n_cascade_levels, n_models)
        print("Saving skill: ", current_skill, currentdate, outdir_path)
        save_skill(
            current_skill, currentdate, outdir_path, n_models=n_models, window_length=2
        )
        currentdate += timestep

    skill_today_file = join(outdir_path, "NWP_skill_today.pkl")
    assert exists(skill_today_file)
    with open(skill_today_file, "rb") as f:
        skill_today = pickle.load(f)

    # Check type
    assert isinstance(skill_today, dict)
    assert "mean_skill" in skill_today
    assert "n" in skill_today
    assert "last_validtime" in skill_today
    assert_array_equal(skill_today["mean_skill"], expected_skill_today["mean_skill"])
    assert skill_today["n"] == expected_skill_today["n"]
    assert skill_today["last_validtime"] == expected_skill_today["last_validtime"]

    # Finally, check if the clim skill calculation returns an array of values
    clim_skill = calc_clim_skill(
        outdir_path=tmpdir,
        n_cascade_levels=n_cascade_levels,
        n_models=n_models,
        window_length=2,
    )

    assert clim_skill.shape[0] == n_models
    assert clim_skill.shape[1] == n_cascade_levels
Test if the skill are saved correctly and the daily average is computed
pysteps/tests/test_blending_clim.py