azogue / aiopvpc

Simple aio library to download Spanish electricity hourly prices (PVPC) from esios.ree.es
MIT License
41 stars 10 forks source link

Test failures with holidays-0.13 #44

Closed fabaff closed 1 year ago

fabaff commented 2 years ago

With with holidays-0.13 there are three failures. 0.13 contains some changes for Spain.

https://github.com/dr-prodigy/python-holidays/pull/634 contains a change around the Spanish holidays but it doesn't help to get the aiopvpc tests to pass.

============================= test session starts ==============================
platform linux -- Python 3.10.2, pytest-6.2.5, py-1.11.0, pluggy-1.0.0 -- /nix/store/c6dwl65z7z9vyadfzp5aqbfv6bi1afnz-python3-3.10.2/bin/python3.10
cachedir: .pytest_cache
rootdir: /build/source, configfile: pyproject.toml, testpaths: tests
plugins: asyncio-0.17.2, timeout-2.0.2
asyncio: mode=legacy
collected 46 items / 4 deselected / 42 selected  
[...]
=================================== FAILURES ===================================
_________________ test_number_of_national_holidays[2021-104-7] _________________

year = 2021, days_weekend_p3 = 104, extra_days_p3 = 7

    @pytest.mark.parametrize(
        "year, days_weekend_p3, extra_days_p3",
        (
            (2021, 104, 7),
            (2022, 105, 7),
            (2023, 105, 9),
        ),
    )
    def test_number_of_national_holidays(year, days_weekend_p3, extra_days_p3):
        """Calculate days with full P3 valley period."""
        holidays_p3 = weekend_days_p3 = 0
        day = datetime(year, 1, 1, 15, tzinfo=REFERENCE_TZ)
        while day.year == year:
            period, _, _ = get_current_and_next_tariff_periods(day, False)
            if period == "P3":
                if day.isoweekday() > 5:
                    weekend_days_p3 += 1
                else:
                    holidays_p3 += 1
            day += timedelta(days=1)
        assert weekend_days_p3 == days_weekend_p3
>       assert holidays_p3 == extra_days_p3
E       assert 8 == 7
E         +8
E         -7

tests/test_tariff_attributes.py:34: AssertionError
[...]
    warnings.warn(

-- Docs: https://docs.pytest.org/en/stable/warnings.html
=========================== short test summary info ============================
FAILED tests/test_tariff_attributes.py::test_number_of_national_holidays[2021-104-7]
FAILED tests/test_tariff_attributes.py::test_number_of_national_holidays[2022-105-7]
FAILED tests/test_tariff_attributes.py::test_number_of_national_holidays[2023-105-9]
=========== 3 failed, 39 passed, 4 deselected, 2 warnings in 19.93s ============

Could you please take a look? I guess that you are more familiar with Spanish holidays than I am. Thanks.

azogue commented 1 year ago

Sorry @fabaff, this old issue went totally unnoticed 🙈

I'm going to resume development on this over the next few days, I'll probably make a few PRs...

This one should be easy to fix, but I think using holidays here it's overkill, I'll probably just remove the dependency 🌬️👍

Sorry about the lack of feedback 😢