|
2 | 2 | from grass.jupyter import TimeSeriesMap
|
3 | 3 |
|
4 | 4 | def test_timeseriesmap_render():
|
5 |
| - """Test if TimeSeriesMap renders layers correctly.""" |
6 |
| - |
7 |
| - # Create TimeSeriesMap instance |
| 5 | + """Test if TimeSeriesMap renders layers, overlays, and legends correctly.""" |
| 6 | + |
| 7 | + # Create instance |
8 | 8 | precip_map = TimeSeriesMap(use_region=True)
|
9 |
| - |
| 9 | + |
10 | 10 | # Add raster series
|
11 | 11 | precip_map.add_raster_series("precip_sum_2018")
|
12 |
| - |
13 |
| - # Add overlays (Legend, Boundary, and Scale bar) |
14 |
| - precip_map.d_legend(color="black", at=(10, 40, 2, 6)) |
| 12 | + |
| 13 | + # Add overlays (boundary, scalebar, legend) |
15 | 14 | precip_map.d_vect(map="boundary_country", fill_color="none")
|
16 | 15 | precip_map.d_barscale()
|
17 |
| - |
18 |
| - # Render the map |
19 |
| - precip_map.show() |
20 |
| - |
21 |
| - # Assert that the map object has layers |
22 |
| - assert precip_map._layers is not None |
23 |
| - assert len(precip_map._layers) > 0 |
| 16 | + precip_map.d_legend(color="black", at=(10, 40, 2, 6)) |
| 17 | + |
| 18 | + # Render frames (headless) |
| 19 | + precip_map.render() |
| 20 | + |
| 21 | + # Verify layers |
| 22 | + assert precip_map._layers is not None, "No layers loaded" |
| 23 | + assert len(precip_map._layers) > 0, "Layers list is empty" |
| 24 | + |
| 25 | + # Verify overlays (d_vect and d_barscale) |
| 26 | + assert len(precip_map._base_calls) >= 2, ( |
| 27 | + f"Expected ≥2 overlay calls, got {len(precip_map._base_calls)}" |
| 28 | + ) |
| 29 | + |
| 30 | + # Verify legend |
| 31 | + assert precip_map._legend == { |
| 32 | + "color": "black", |
| 33 | + "at": (10, 40, 2, 6), |
| 34 | + }, "Legend not configured correctly" |
0 commit comments