-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: make all files have LF line endrings
- Loading branch information
Showing
9 changed files
with
827 additions
and
827 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,68 @@ | ||
"""Tests for reading tibber.TibberHome properties from cached values after the Tibber account is initialized.""" | ||
import pytest | ||
|
||
import tibber | ||
from tibber.types import LegalEntity | ||
from tibber.types import MeteringPointData | ||
from tibber.types import Subscription | ||
from tibber.types import HomeFeatures | ||
from tibber.types import Address | ||
|
||
|
||
def test_getting_id(home): | ||
assert home.id == "96a14971-525a-4420-aae9-e5aedaa129ff" | ||
|
||
def test_getting_time_zome(home): | ||
assert home.time_zone == "Europe/Stockholm" | ||
|
||
def test_getting_app_nickname(home): | ||
assert home.app_nickname == "Vitahuset" | ||
|
||
def test_getting_size(home): | ||
assert home.size == 200 | ||
|
||
def test_getting_type(home): | ||
assert home.type == "HOUSE" | ||
|
||
def test_getting_number_of_residents(home): | ||
assert home.number_of_residents == 5 | ||
|
||
def test_getting_primary_heating_source(home): | ||
assert home.primary_heating_source == "GROUND" | ||
|
||
def test_getting_has_ventilation_system(home): | ||
assert home.has_ventilation_system == False | ||
|
||
def test_getting_main_fuse_size(home): | ||
assert home.main_fuse_size == 25 | ||
|
||
def test_getting_owner(home): | ||
assert isinstance(home.owner, LegalEntity) | ||
|
||
def test_getting_metering_point_data(home): | ||
assert isinstance(home.metering_point_data, MeteringPointData) | ||
|
||
# TODO: Move to an own test file | ||
data = home.metering_point_data | ||
assert data.consumption_ean == "735999102107573183" | ||
assert data.grid_company == "Ellevio AB" | ||
assert data.grid_area_code == "STH" | ||
assert data.price_area_code == "SE3" | ||
assert data.production_ean == "735999102111362582" | ||
assert data.energy_tax_type == "normal" | ||
|
||
def test_getting_current_subscription(home): | ||
assert isinstance(home.current_subscription, Subscription) | ||
|
||
def test_getting_subscriptions(home): | ||
assert len(home.subscriptions) == 1 | ||
assert isinstance(home.subscriptions[0], Subscription) | ||
|
||
def test_getting_features(home): | ||
assert isinstance(home.features, HomeFeatures) | ||
|
||
def test_getting_address(home): | ||
assert isinstance(home.address, Address) | ||
|
||
def test_getting_address1(home): | ||
assert home.address1 == "Winterfell Castle 1" | ||
"""Tests for reading tibber.TibberHome properties from cached values after the Tibber account is initialized.""" | ||
import pytest | ||
|
||
import tibber | ||
from tibber.types import LegalEntity | ||
from tibber.types import MeteringPointData | ||
from tibber.types import Subscription | ||
from tibber.types import HomeFeatures | ||
from tibber.types import Address | ||
|
||
|
||
def test_getting_id(home): | ||
assert home.id == "96a14971-525a-4420-aae9-e5aedaa129ff" | ||
|
||
def test_getting_time_zome(home): | ||
assert home.time_zone == "Europe/Stockholm" | ||
|
||
def test_getting_app_nickname(home): | ||
assert home.app_nickname == "Vitahuset" | ||
|
||
def test_getting_size(home): | ||
assert home.size == 200 | ||
|
||
def test_getting_type(home): | ||
assert home.type == "HOUSE" | ||
|
||
def test_getting_number_of_residents(home): | ||
assert home.number_of_residents == 5 | ||
|
||
def test_getting_primary_heating_source(home): | ||
assert home.primary_heating_source == "GROUND" | ||
|
||
def test_getting_has_ventilation_system(home): | ||
assert home.has_ventilation_system == False | ||
|
||
def test_getting_main_fuse_size(home): | ||
assert home.main_fuse_size == 25 | ||
|
||
def test_getting_owner(home): | ||
assert isinstance(home.owner, LegalEntity) | ||
|
||
def test_getting_metering_point_data(home): | ||
assert isinstance(home.metering_point_data, MeteringPointData) | ||
|
||
# TODO: Move to an own test file | ||
data = home.metering_point_data | ||
assert data.consumption_ean == "735999102107573183" | ||
assert data.grid_company == "Ellevio AB" | ||
assert data.grid_area_code == "STH" | ||
assert data.price_area_code == "SE3" | ||
assert data.production_ean == "735999102111362582" | ||
assert data.energy_tax_type == "normal" | ||
|
||
def test_getting_current_subscription(home): | ||
assert isinstance(home.current_subscription, Subscription) | ||
|
||
def test_getting_subscriptions(home): | ||
assert len(home.subscriptions) == 1 | ||
assert isinstance(home.subscriptions[0], Subscription) | ||
|
||
def test_getting_features(home): | ||
assert isinstance(home.features, HomeFeatures) | ||
|
||
def test_getting_address(home): | ||
assert isinstance(home.address, Address) | ||
|
||
def test_getting_address1(home): | ||
assert home.address1 == "Winterfell Castle 1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
"""Tests for fetching consumption data from the API.""" | ||
from datetime import datetime | ||
from datetime import timedelta | ||
|
||
import pytest | ||
|
||
import tibber | ||
|
||
|
||
def test_consumption_page_info(home): | ||
home_consumption_connection = home.fetch_consumption("HOURLY", first=5, after="MjAyMy0wMi0wNlQwMTowMDowMC4wMDArMDE6MDA=") | ||
page_info = home_consumption_connection.page_info | ||
|
||
assert page_info.end_cursor == home_consumption_connection.edges[-1].cursor | ||
assert page_info.has_next_page | ||
assert page_info.has_previous_page | ||
assert page_info.start_cursor == home_consumption_connection.edges[0].cursor | ||
|
||
assert page_info.count == 5 | ||
assert page_info.currency == "SEK" | ||
assert page_info.total_cost == 25.4909709625 | ||
assert page_info.total_consumption == 16.633 | ||
assert page_info.filtered == 0 | ||
|
||
def test_consumption_nodes(home): | ||
home_consumption_connection = home.fetch_consumption("HOURLY", first=3, after="MjAyMy0wMi0wNlQwMTowMDowMC4wMDArMDE6MDA=") | ||
history = home_consumption_connection.nodes | ||
|
||
assert history[0].from_time == "2023-02-06T01:00:00.000+01:00" | ||
assert history[0].to_time == "2023-02-06T02:00:00.000+01:00" | ||
|
||
assert [node.cost for node in history] == [3.8449054875, 4.416853275, 5.561462025] | ||
assert [node.unit_price for node in history] == [1.3290375, 1.2455875, 1.401225] | ||
assert [node.unit_price_vat for node in history] == [0.2658075, 0.2491175, 0.280245] | ||
assert [node.consumption for node in history] == [2.893, 3.546, 3.969] | ||
assert all(node.consumption_unit == "kWh" for node in history) | ||
"""Tests for fetching consumption data from the API.""" | ||
from datetime import datetime | ||
from datetime import timedelta | ||
|
||
import pytest | ||
|
||
import tibber | ||
|
||
|
||
def test_consumption_page_info(home): | ||
home_consumption_connection = home.fetch_consumption("HOURLY", first=5, after="MjAyMy0wMi0wNlQwMTowMDowMC4wMDArMDE6MDA=") | ||
page_info = home_consumption_connection.page_info | ||
|
||
assert page_info.end_cursor == home_consumption_connection.edges[-1].cursor | ||
assert page_info.has_next_page | ||
assert page_info.has_previous_page | ||
assert page_info.start_cursor == home_consumption_connection.edges[0].cursor | ||
|
||
assert page_info.count == 5 | ||
assert page_info.currency == "SEK" | ||
assert page_info.total_cost == 25.4909709625 | ||
assert page_info.total_consumption == 16.633 | ||
assert page_info.filtered == 0 | ||
|
||
def test_consumption_nodes(home): | ||
home_consumption_connection = home.fetch_consumption("HOURLY", first=3, after="MjAyMy0wMi0wNlQwMTowMDowMC4wMDArMDE6MDA=") | ||
history = home_consumption_connection.nodes | ||
|
||
assert history[0].from_time == "2023-02-06T01:00:00.000+01:00" | ||
assert history[0].to_time == "2023-02-06T02:00:00.000+01:00" | ||
|
||
assert [node.cost for node in history] == [3.8449054875, 4.416853275, 5.561462025] | ||
assert [node.unit_price for node in history] == [1.3290375, 1.2455875, 1.401225] | ||
assert [node.unit_price_vat for node in history] == [0.2658075, 0.2491175, 0.280245] | ||
assert [node.consumption for node in history] == [2.893, 3.546, 3.969] | ||
assert all(node.consumption_unit == "kWh" for node in history) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
"""Tests fetching historical price data.""" | ||
import base64 | ||
from datetime import datetime | ||
from datetime import timezone | ||
from datetime import timedelta | ||
|
||
import pytest | ||
|
||
import tibber | ||
|
||
|
||
def test_fetching_hourly_prices(home): | ||
date = datetime(2025, 1, 1, 0, 0, 0, tzinfo=timezone(timedelta(hours=1))) | ||
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" | ||
"""Tests fetching historical price data.""" | ||
import base64 | ||
from datetime import datetime | ||
from datetime import timezone | ||
from datetime import timedelta | ||
|
||
import pytest | ||
|
||
import tibber | ||
|
||
|
||
def test_fetching_hourly_prices(home): | ||
date = datetime(2025, 1, 1, 0, 0, 0, tzinfo=timezone(timedelta(hours=1))) | ||
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.