Skip to content

Commit 8ab69ab

Browse files
committed
test: smoke tests for Raw and Pandas clients
1 parent 6f70af5 commit 8ab69ab

File tree

4 files changed

+317
-161
lines changed

4 files changed

+317
-161
lines changed

tests/test_clients.py

Lines changed: 0 additions & 113 deletions
This file was deleted.

tests/test_domains.py

Lines changed: 0 additions & 48 deletions
This file was deleted.

tests/test_pandas.py

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
from itertools import product
2+
3+
from entsoe import EntsoePandasClient
4+
import pandas as pd
5+
import pytest
6+
7+
from settings import api_key
8+
9+
10+
@pytest.fixture
11+
def client():
12+
yield EntsoePandasClient(api_key=api_key)
13+
14+
15+
@pytest.fixture
16+
def start():
17+
return pd.Timestamp("20171201", tz="Europe/Brussels")
18+
19+
20+
@pytest.fixture
21+
def end():
22+
return pd.Timestamp("20180101", tz="Europe/Brussels")
23+
24+
25+
@pytest.fixture
26+
def country_code():
27+
return "BE" # Belgium
28+
29+
30+
@pytest.fixture
31+
def country_code_from():
32+
return "FR" # France
33+
34+
35+
@pytest.fixture
36+
def country_code_to():
37+
return "DE_LU" # Germany-Luxembourg
38+
39+
40+
STARTS = [pd.Timestamp("20171201", tz="Europe/Brussels")]
41+
ENDS = [pd.Timestamp("20180101", tz="Europe/Brussels")]
42+
COUNTRY_CODES = ["BE"] # Belgium
43+
COUNTRY_CODES_FROM = ["FR"] # France
44+
COUNTRY_CODES_TO = ["DE_LU"] # Germany-Luxembourg
45+
46+
BASIC_QUERIES_SERIES = [
47+
"query_day_ahead_prices",
48+
"query_net_position_dayahead",
49+
"query_load",
50+
"query_load_forecast",
51+
]
52+
53+
BASIC_QUERIES_DATAFRAME = [
54+
"query_wind_and_solar_forecast",
55+
"query_generation_forecast",
56+
"query_generation",
57+
"query_generation_per_plant",
58+
"query_installed_generation_capacity",
59+
"query_installed_generation_capacity_per_unit",
60+
"query_imbalance_prices",
61+
"query_withdrawn_unavailability_of_generation_units",
62+
"query_unavailability_of_generation_units",
63+
"query_unavailability_of_production_units",
64+
"query_import",
65+
"query_generation_import",
66+
]
67+
68+
CROSSBORDER_QUERIES = [
69+
"query_crossborder_flows",
70+
"query_scheduled_exchanges",
71+
"query_net_transfer_capacity_dayahead",
72+
"query_net_transfer_capacity_weekahead",
73+
"query_net_transfer_capacity_monthahead",
74+
"query_net_transfer_capacity_yearahead",
75+
"query_intraday_offered_capacity",
76+
]
77+
78+
# pandas.Series
79+
80+
@pytest.mark.parametrize(
81+
"country_code, start, end, query",
82+
product(COUNTRY_CODES, STARTS, ENDS, BASIC_QUERIES_SERIES),
83+
)
84+
def test_basic_queries_series(client, query, country_code, start, end):
85+
result = getattr(client, query)(country_code, start=start, end=end)
86+
assert not result.empty
87+
88+
89+
@pytest.mark.parametrize(
90+
"country_code_from, country_code_to, start, end, query",
91+
product(COUNTRY_CODES_FROM, COUNTRY_CODES_TO, STARTS, ENDS, CROSSBORDER_QUERIES),
92+
)
93+
def test_crossborder_queries(
94+
client, query, country_code_from, country_code_to, start, end
95+
):
96+
result = getattr(client, query)(country_code_from, country_code_to, start=start, end=end)
97+
assert not result.empty
98+
99+
# pandas.DataFrames
100+
101+
@pytest.mark.parametrize(
102+
"country_code, start, end, query",
103+
product(COUNTRY_CODES, STARTS, ENDS, BASIC_QUERIES_DATAFRAME),
104+
)
105+
def test_basic_queries_dataframe(client, query, country_code, start, end):
106+
result = getattr(client, query)(country_code, start=start, end=end)
107+
assert not result.empty
108+
109+
110+
def test_query_contracted_reserve_prices(client, country_code, start, end):
111+
type_marketagreement_type = "A01"
112+
result = client.query_contracted_reserve_prices(
113+
country_code, start=start, end=end, type_marketagreement_type=type_marketagreement_type
114+
)
115+
assert not result.empty
116+
117+
118+
def test_query_contracted_reserve_amount(client, country_code, start, end):
119+
type_marketagreement_type = "A01"
120+
result = client.query_contracted_reserve_amount(
121+
country_code, start=start, end=end, type_marketagreement_type=type_marketagreement_type
122+
)
123+
assert not result.empty
124+
125+
126+
def test_query_unavailability_transmission(client, country_code_from, country_code_to, start, end):
127+
result = client.query_unavailability_transmission(
128+
country_code_from, country_code_to, start=start, end=end
129+
)
130+
assert not result.empty
131+
132+
133+
def test_query_procured_balancing_capacity_process_type_not_allowed(client, country_code, start, end):
134+
process_type = "A01"
135+
with pytest.raises(ValueError):
136+
client.query_procured_balancing_capacity(
137+
country_code, start=start, end=end, process_type=process_type
138+
)
139+
140+
141+
def test_query_procured_balancing_capacity(client, country_code, start, end):
142+
process_type = "A47"
143+
result = client.query_procured_balancing_capacity(
144+
country_code, start=start, end=end, process_type=process_type
145+
)
146+
assert not result.empty

0 commit comments

Comments
 (0)