Skip to content

Commit

Permalink
test: add test for range function on PriceInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
BeatsuDev committed Jan 6, 2025
1 parent c2d345d commit d83051e
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/fetched/test_range.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Tests fetching historical price data."""
import base64
from datetime import datetime
from datetime import timedelta

import pytest

import tibber


def test_fetching_hourly_prices(home):
date = datetime(2025, 1, 1, 0, 0, 0)
encoded = base64.b64encode(date.astimezone().isoformat().encode("utf-8")).decode("utf-8")

data = home.current_subscription.price_info.fetch_range("HOURLY", first="3", after=encoded)

assert data.page_info.count == 3
assert len(data.nodes) == 3

assert data.nodes[0].starts_at == "2025-01-01T00:00:00.000+01:00"
assert data.nodes[1].starts_at == "2025-01-01T01:00:00.000+01:00"
assert data.nodes[2].starts_at == "2025-01-01T02:00:00.000+01:00"

0 comments on commit d83051e

Please sign in to comment.