Skip to content

Commit 2854508

Browse files
committed
Updated tests to reflect changes in DEMO account
1 parent 671d72e commit 2854508

File tree

8 files changed

+69
-66
lines changed

8 files changed

+69
-66
lines changed

tests/cached/test_account.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ def test_getting_name(account):
1818
assert account.name == "Arya Stark"
1919

2020
def test_getting_login(account):
21-
assert account.login == "edgeir@tibber.com"
21+
assert account.login == "arya@winterfell.com"
2222

2323
def test_getting_user_id(account):
24-
assert account.user_id == "df4b53bf-0709-4679-8744-08876cbb03c1"
24+
assert account.user_id == "dcc2355e-6f55-45c2-beb9-274241fe450c"
2525

2626
def test_getting_account_type(account):
2727
assert account.account_type == ["tibber", "customer"]

tests/cached/test_home.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,31 +18,31 @@ def home():
1818
raise ValueError("The instanciated demo account does not have any homes. Cannot perform home tests.")
1919

2020
def test_getting_id(home):
21-
assert home.id == "cc83e83e-8cbf-4595-9bf7-c3cf192f7d9c"
21+
assert home.id == "96a14971-525a-4420-aae9-e5aedaa129ff"
2222

2323
def test_getting_time_zome(home):
24-
assert home.time_zone == "Europe/Oslo"
24+
assert home.time_zone == "Europe/Stockholm"
2525

2626
def test_getting_app_nickname(home):
27-
assert home.app_nickname == "Ulltang casa"
27+
assert home.app_nickname == "Vitahuset"
2828

2929
def test_getting_size(home):
30-
assert home.size == 200
30+
assert home.size == 195
3131

3232
def test_getting_type(home):
3333
assert home.type == "HOUSE"
3434

3535
def test_getting_number_of_residents(home):
36-
assert home.number_of_residents == 4
36+
assert home.number_of_residents == 5
3737

3838
def test_getting_primary_heating_source(home):
39-
assert home.primary_heating_source == "AIR2AIR_HEATPUMP"
39+
assert home.primary_heating_source == "GROUND"
4040

4141
def test_getting_has_ventilation_system(home):
42-
assert home.has_ventilation_system == True
42+
assert home.has_ventilation_system == False
4343

4444
def test_getting_main_fuse_size(home):
45-
assert home.main_fuse_size == 63
45+
assert home.main_fuse_size == 25
4646

4747
def test_getting_owner(home):
4848
assert isinstance(home.owner, LegalEntity)
@@ -52,18 +52,18 @@ def test_getting_metering_point_data(home):
5252

5353
# TODO: Move to an own test file
5454
data = home.metering_point_data
55-
assert data.consumption_ean == "707057500084125027"
56-
assert data.grid_company == "Sunnfjord Energi AS Nett"
57-
assert data.grid_area_code == "50YK05ZHDDCGA4AK"
58-
assert data.price_area_code == "NO3"
59-
assert data.production_ean == "707057500084125027P"
60-
assert data.energy_tax_type == "none"
55+
assert data.consumption_ean == "735999102107573183"
56+
assert data.grid_company == "Ellevio AB"
57+
assert data.grid_area_code == "STH"
58+
assert data.price_area_code == "SE3"
59+
assert data.production_ean == "735999102111362582"
60+
assert data.energy_tax_type == "normal"
6161

6262
def test_getting_current_subscription(home):
6363
assert isinstance(home.current_subscription, Subscription)
6464

6565
def test_getting_subscriptions(home):
66-
assert len(home.subscriptions) == 2
66+
assert len(home.subscriptions) == 1
6767
assert isinstance(home.subscriptions[0], Subscription)
6868

6969
def test_getting_features(home):

tests/cached/test_home_features.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ def home():
1414

1515

1616
def test_real_time_consumption(home):
17-
assert not home.features.real_time_consumption_enabled
17+
assert home.features.real_time_consumption_enabled

tests/cached/test_legal_entity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def test_correct_type(legal_entity):
1616
assert isinstance(legal_entity, LegalEntity)
1717

1818
def test_getting_id(legal_entity):
19-
assert legal_entity.id == "df4b53bf-0709-4679-8744-08876cbb03c1"
19+
assert legal_entity.id == "dcc2355e-6f55-45c2-beb9-274241fe450c"
2020

2121
def test_getting_first_name(legal_entity):
2222
assert legal_entity.first_name == "Arya"

tests/cached/test_subscription.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ def test_correct_type(subscription):
2121
assert isinstance(subscription, Subscription)
2222

2323
def test_getting_id(subscription):
24-
assert subscription.id == "e9c0f9eb-4a7d-447f-8598-0794c33ca5aa"
24+
assert subscription.id == "a386fd22-579e-4364-8b17-c63bef0d6bee"
2525

2626
def test_getting_subscriber(subscription):
2727
assert isinstance(subscription.subscriber, LegalEntity)
2828

2929
def test_getting_valid_from(subscription):
30-
assert subscription.valid_from == "2020-04-26T22:00:00+00:00"
30+
assert subscription.valid_from == "2018-11-01T23:00:00+00:00"
3131

3232
def test_getting_status(subscription):
33-
assert subscription.status == "ended"
33+
assert subscription.status == "running"
3434

3535
def test_getting_price_info(subscription):
3636
assert isinstance(subscription.price_info, PriceInfo)

tests/fetched/test_consumption.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,28 @@ def home():
1616
raise ValueError("The instanciated demo account does not have any homes. Cannot perform home tests.")
1717

1818
def test_consumption_page_info(home):
19-
home_consumption_connection = home.fetch_consumption("HOURLY", first=4, after="MjAyMC0wNC0yN1QxOTowMDowMC4wMDArMDI6MDA=")
19+
home_consumption_connection = home.fetch_consumption("HOURLY", first=5, after="MjAxOC0xMS0wM1QyMDowMDowMC4wMDArMDE6MDA=")
2020
page_info = home_consumption_connection.page_info
2121

2222
assert page_info.end_cursor == home_consumption_connection.edges[-1].cursor
2323
assert page_info.has_next_page
2424
assert page_info.has_previous_page
2525
assert page_info.start_cursor == home_consumption_connection.edges[0].cursor
2626

27-
assert page_info.count == 4
28-
assert page_info.currency == "NOK"
29-
assert page_info.total_cost == 0.6131657916666666
30-
assert page_info.total_consumption == 4.401
27+
assert page_info.count == 5
28+
assert page_info.currency == "SEK"
29+
assert page_info.total_cost == 6.151398125
30+
assert page_info.total_consumption == 9.45
3131
assert page_info.filtered == 0
3232

3333
def test_consumption_nodes(home):
3434
home_consumption_connection = home.fetch_consumption("HOURLY", first=5)
3535
history = home_consumption_connection.nodes
3636

37-
assert history[0].from_time == "2020-04-27T00:00:00.000+02:00"
38-
assert history[0].to_time == "2020-04-27T01:00:00.000+02:00"
37+
assert history[0].from_time == "2018-11-02T00:00:00.000+01:00"
38+
assert history[0].to_time == "2018-11-02T01:00:00.000+01:00"
3939

40-
assert [node.unit_price for node in history] == [0.0913625, 0.0903625, 0.0903625, 0.0905, 0.09165]
41-
assert [node.unit_price_vat for node in history] == [0.0182725, 0.0180725, 0.0180725, 0.0181, 0.01833]
42-
assert [node.consumption_unit == "kWh" for node in history]
40+
assert [node.unit_price for node in history] == [0.6300375, 0.614075, 0.61175, 0.6085375, 0.6163875]
41+
assert [node.unit_price_vat for node in history] == [0.1260075, 0.122815, 0.12235, 0.1217075, 0.1232775]
42+
assert all(node.consumption_unit == "kWh" for node in history)
4343

tests/fetched/test_production.py

Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,38 @@ def home():
1515
except IndexError:
1616
raise ValueError("The instanciated demo account does not have any homes. Cannot perform home tests.")
1717

18-
def test_production_page_info(home):
19-
home_production_connection = home.fetch_production("HOURLY", first=10, after="MjAyMi0wNi0xNFQxMzowMDowMC4wMDArMDI6MDA=")
20-
page_info = home_production_connection.page_info
21-
22-
assert page_info.end_cursor == home_production_connection.edges[-1].cursor
23-
assert page_info.has_next_page
24-
assert page_info.has_previous_page
25-
assert page_info.start_cursor == home_production_connection.edges[0].cursor
26-
27-
assert page_info.count == 10
28-
assert page_info.currency == "NOK"
29-
assert page_info.total_profit == 0.73834817
30-
assert page_info.total_production == 5.49
31-
assert page_info.filtered == 0
32-
33-
def test_production_nodes(home):
34-
home_production_connection = home.fetch_production("HOURLY", last=5)
35-
history = home_production_connection.nodes
36-
37-
for i, hour in enumerate(history):
38-
from_time = datetime.strptime(hour.from_time, "%Y-%m-%dT%H:%M:%S.%f%z")
39-
to_time = datetime.strptime(hour.to_time, "%Y-%m-%dT%H:%M:%S.%f%z")
40-
41-
ft = datetime.now().astimezone().replace(minute=0, second=0, microsecond=0)
42-
ft -= timedelta(hours=1+(4 - i))
43-
tt = datetime.now().astimezone().replace(minute=0, second=0, microsecond=0)
44-
tt -= timedelta(hours=(4 - i))
45-
46-
assert from_time == ft
47-
assert to_time == tt
48-
49-
assert [node.production_unit == "kWh" for node in history]
18+
19+
# DISABLED in version 0.1.1 because the demo account has no power production...
20+
21+
# def test_production_page_info(home):
22+
# home_production_connection = home.fetch_production("HOURLY", first=10, after="MjAyMi0wNi0xNFQxMzowMDowMC4wMDArMDI6MDA=")
23+
# page_info = home_production_connection.page_info
24+
25+
# assert page_info.end_cursor == home_production_connection.edges[-1].cursor
26+
# assert page_info.has_next_page
27+
# assert page_info.has_previous_page
28+
# assert page_info.start_cursor == home_production_connection.edges[0].cursor
29+
30+
# assert page_info.count == 10
31+
# assert page_info.currency == "NOK"
32+
# assert page_info.total_profit == 0.73834817
33+
# assert page_info.total_production == 5.49
34+
# assert page_info.filtered == 0
35+
36+
# def test_production_nodes(home):
37+
# home_production_connection = home.fetch_production("HOURLY", last=5)
38+
# history = home_production_connection.nodes
39+
40+
# for i, hour in enumerate(history):
41+
# from_time = datetime.strptime(hour.from_time, "%Y-%m-%dT%H:%M:%S.%f%z")
42+
# to_time = datetime.strptime(hour.to_time, "%Y-%m-%dT%H:%M:%S.%f%z")
43+
44+
# ft = datetime.now().astimezone().replace(minute=0, second=0, microsecond=0)
45+
# ft -= timedelta(hours=1+(4 - i))
46+
# tt = datetime.now().astimezone().replace(minute=0, second=0, microsecond=0)
47+
# tt -= timedelta(hours=(4 - i))
48+
49+
# assert from_time == ft
50+
# assert to_time == tt
51+
52+
# assert [node.production_unit == "kWh" for node in history]

tibber/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
__version__ = "0.1.0"
2-
DEMO_TOKEN = "476c477d8a039529478ebd690d35ddd80e3308ffc49b59c65b142321aee963a4"
1+
__version__ = "0.1.1"
2+
DEMO_TOKEN = "5K4MVS-OjfWhK_4yrjOlFe1F6kJXPVf7eQYggo8ebAE"
33
API_ENDPOINT = "https://api.tibber.com/v1-beta/gql"
44
SUBSCRIPTION_ENDPOINT = "wss://api.tibber.com/v1-beta/gql/subscriptions"
55

0 commit comments

Comments
 (0)