|
9 | 9 |
|
10 | 10 |
|
11 | 11 | # Country-specific configuration for parametrized tests |
12 | | -NL_CONFIG = { |
| 12 | +NL_NATIONAL_CONFIG = { |
13 | 13 | "country": "nl", |
14 | 14 | "observer_name": "nednl", |
15 | 15 | "locations": [ |
|
21 | 21 | "geometry": "POINT(5.29 52.13)", |
22 | 22 | "capacity": 100_000_000_000, |
23 | 23 | }, |
| 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": [ |
24 | 44 | { |
25 | 45 | "name": "nl_groningen", |
26 | 46 | "metadata_key": "region_id", |
|
32 | 52 | ], |
33 | 53 | "test_data": { |
34 | 54 | "target_datetime_utc": [ |
35 | | - pd.to_datetime("2025-01-01T00:00:00Z"), |
36 | | - pd.to_datetime("2025-01-01T01:00:00Z"), |
37 | 55 | pd.to_datetime("2025-01-01T02:00:00Z"), |
38 | 56 | pd.to_datetime("2025-01-01T03:00:00Z"), |
39 | 57 | ], |
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], |
43 | 61 | }, |
44 | 62 | "capacity_updates": { |
45 | | - "nl_national": 80_000_000_000, |
46 | 63 | "nl_groningen": 60_000_000_000, |
47 | 64 | }, |
48 | 65 | "id_column": "region_id", |
49 | 66 | } |
50 | 67 |
|
| 68 | + |
51 | 69 | BE_CONFIG = { |
52 | 70 | "country": "be", |
53 | 71 | "observer_name": "elia_be", |
|
94 | 112 |
|
95 | 113 |
|
96 | 114 | @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 | +) |
98 | 120 | async def test_save_generation_to_data_platform(client, config): |
99 | 121 | """ |
100 | 122 | Test saving generation data to the Data Platform. |
@@ -132,9 +154,12 @@ async def test_save_generation_to_data_platform(client, config): |
132 | 154 | create_location_response = await client.create_location(create_location_request) |
133 | 155 | location_uuids[loc_config["name"]] = create_location_response.location_uuid |
134 | 156 |
|
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)) |
138 | 163 |
|
139 | 164 | # Create fake generation data |
140 | 165 | fake_data = pd.DataFrame(config["test_data"]) |
|
0 commit comments