Skip to content

Commit 2c2e2da

Browse files
test in isolation
1 parent d2080dc commit 2c2e2da

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

tests/integration/test_save_nl_and_be_to_data_platform.py

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010

1111
# Country-specific configuration for parametrized tests
12-
NL_CONFIG = {
12+
NL_NATIONAL_CONFIG = {
1313
"country": "nl",
1414
"observer_name": "nednl",
1515
"locations": [
@@ -21,6 +21,26 @@
2121
"geometry": "POINT(5.29 52.13)",
2222
"capacity": 100_000_000_000,
2323
},
24+
],
25+
"test_data": {
26+
"target_datetime_utc": [
27+
pd.to_datetime("2025-01-01T00:00:00Z"),
28+
pd.to_datetime("2025-01-01T01:00:00Z"),
29+
],
30+
"solar_generation_kw": [5000.0, 6000.0],
31+
"region_id": [0, 0],
32+
"capacity_kw": [80_000_000, 80_000_000],
33+
},
34+
"capacity_updates": {
35+
"nl_national": 80_000_000_000,
36+
},
37+
"id_column": "region_id",
38+
}
39+
40+
NL_GRONINGEN_CONFIG = {
41+
"country": "nl",
42+
"observer_name": "nednl",
43+
"locations": [
2444
{
2545
"name": "nl_groningen",
2646
"metadata_key": "region_id",
@@ -32,22 +52,20 @@
3252
],
3353
"test_data": {
3454
"target_datetime_utc": [
35-
pd.to_datetime("2025-01-01T00:00:00Z"),
36-
pd.to_datetime("2025-01-01T01:00:00Z"),
3755
pd.to_datetime("2025-01-01T02:00:00Z"),
3856
pd.to_datetime("2025-01-01T03:00:00Z"),
3957
],
40-
"solar_generation_kw": [5000.0, 6000.0, 2500.0, 3000.0],
41-
"region_id": [0, 0, 1, 1],
42-
"capacity_kw": [80_000_000, 80_000_000, 60_000_000, 60_000_000],
58+
"solar_generation_kw": [2500.0, 3000.0],
59+
"region_id": [1, 1],
60+
"capacity_kw": [60_000_000, 60_000_000],
4361
},
4462
"capacity_updates": {
45-
"nl_national": 80_000_000_000,
4663
"nl_groningen": 60_000_000_000,
4764
},
4865
"id_column": "region_id",
4966
}
5067

68+
5169
BE_CONFIG = {
5270
"country": "be",
5371
"observer_name": "elia_be",
@@ -94,7 +112,11 @@
94112

95113

96114
@pytest.mark.asyncio(loop_scope="module")
97-
@pytest.mark.parametrize("config", [NL_CONFIG, BE_CONFIG], ids=["nl", "be"])
115+
@pytest.mark.parametrize(
116+
"config",
117+
[NL_NATIONAL_CONFIG, NL_GRONINGEN_CONFIG, BE_CONFIG],
118+
ids=["nl_national", "nl_groningen", "be"],
119+
)
98120
async def test_save_generation_to_data_platform(client, config):
99121
"""
100122
Test saving generation data to the Data Platform.
@@ -132,9 +154,12 @@ async def test_save_generation_to_data_platform(client, config):
132154
create_location_response = await client.create_location(create_location_request)
133155
location_uuids[loc_config["name"]] = create_location_response.location_uuid
134156

135-
# Create observer
136-
create_observer_request = dp.CreateObserverRequest(name=observer_name)
137-
await client.create_observer(create_observer_request)
157+
# Create observer (only if it doesn't already exist - tests share the same DB in module scope)
158+
list_observer_response = await client.list_observers(
159+
dp.ListObserversRequest(observer_names_filter=[observer_name])
160+
)
161+
if not any(obs.observer_name == observer_name for obs in list_observer_response.observers):
162+
await client.create_observer(dp.CreateObserverRequest(name=observer_name))
138163

139164
# Create fake generation data
140165
fake_data = pd.DataFrame(config["test_data"])

0 commit comments

Comments
 (0)