예제 #1
0
def test_real_download_range():
    # No async
    pvpc_handler = PVPCData("normal")
    start = datetime(2019, 10, 26, 15)
    end = datetime(2019, 10, 28, 13)
    prices = pvpc_handler.download_prices_for_range(start, end)
    assert len(prices) == 48

    no_prices = pvpc_handler.download_prices_for_range(
        datetime(2010, 8, 26, 23), datetime(2010, 8, 27, 22))
    assert len(no_prices) == 0
예제 #2
0
def test_full_data_download_range():
    """Test retrieval of full PVPC data in a day range."""
    start = _TZ_TEST.localize(datetime(2019, 10, 26, 15))
    end = _TZ_TEST.localize(datetime(2019, 10, 27, 13))

    with patch("aiohttp.ClientSession", MockAsyncSession):
        pvpc_data = PVPCData()
        prices = pvpc_data.download_prices_for_range(start, end)

    assert len(prices) == 24
    first_price = min(prices)
    last_price = max(prices)
    assert first_price.hour == 14 and first_price.tzname() == "UTC"
    assert last_price.hour == 13 and last_price.tzname() == "UTC"
    data_first_hour = prices[first_price]

    # Check full PVPC data is retrieved
    assert len(data_first_hour) == 30
    assert all(tag in data_first_hour for tag in ESIOS_TARIFFS)

    # Check units have not changed in full data retrieval (they are in €/MWh)
    assert all(data_first_hour[tag] > 1 for tag in ESIOS_TARIFFS)
예제 #3
0
파일: test_pvpc.py 프로젝트: azogue/aiopvpc
def test_full_data_download_range(timezone, start, end):
    """Test retrieval of full PVPC data in a day range."""
    with patch("aiohttp.ClientSession", MockAsyncSession):
        pvpc_data = PVPCData(local_timezone=timezone)
        prices = pvpc_data.download_prices_for_range(start, end)

    assert len(prices) == 24
    first_price = min(prices)
    last_price = max(prices)
    data_first_hour = prices[first_price]

    # Check full PVPC data is retrieved
    assert len(data_first_hour) == 30
    assert all(tag in data_first_hour for tag in ESIOS_TARIFFS)

    # Check units have not changed in full data retrieval (they are in €/MWh)
    assert all(data_first_hour[tag] > 1 for tag in ESIOS_TARIFFS)

    # check tz-alignment (price at 15h is tz-independent)
    assert prices[first_price]["NOC"] == 119.16
    assert first_price.astimezone(timezone).hour == 15
    assert last_price.astimezone(timezone).hour == 13