-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: write test for plot_capacity_map module
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import bokeh.plotting as plt | ||
import pytest | ||
from powersimdata.tests.mock_scenario import MockScenario | ||
|
||
from postreise.plot.plot_capacity_map import map_plant_capacity | ||
|
||
mock_plant = { | ||
"plant_id": ["A", "B", "C", "D", "E", "F", "G", "H"], | ||
"bus_id": [1, 2, 3, 4, 5, 6, 7, 9], | ||
"lat": [29.7604, 30.2672, 26.183, 31.7619, 32.7555, 30.6280, 31.5493, 29.3013], | ||
"lon": [ | ||
-95.3698, | ||
-97.7431, | ||
-98.123, | ||
-106.4850, | ||
-97.3308, | ||
-96.3344, | ||
-97.1467, | ||
94.7977, | ||
], | ||
"Pmax": [1000, 750, 1500, 300, 500, 300, 200, 800], | ||
"type": ["coal", "ng", "coal", "coal", "wind", "ng", "coal", "solar"], | ||
} | ||
|
||
scenario = MockScenario({"plant": mock_plant}) | ||
|
||
|
||
def test_map_plant_capacity(): | ||
canvas = map_plant_capacity(scenario, ["ng"]) | ||
assert isinstance(canvas, plt.Figure) | ||
|
||
ct = { | ||
"new_plant": [ | ||
{"type": "solar", "bus_id": 9, "Pmax": 800}, | ||
{ | ||
"type": "coal", | ||
"bus_id": 8, | ||
"Pmin": 25, | ||
"Pmax": 200, | ||
"c0": 1800, | ||
"c1": 30, | ||
"c2": 0.0025, | ||
}, | ||
] | ||
} | ||
scenario.state.ct = ct | ||
_ = map_plant_capacity(scenario, ["coal"], disaggregation="new_vs_existing_plants") | ||
|
||
scenario.state.ct = {} | ||
_ = map_plant_capacity(scenario, ["coal"], disaggregation="new_vs_existing_plants") | ||
|
||
_ = map_plant_capacity(scenario, ["hydro", "ng"]) | ||
|
||
|
||
def test_map_plant_capacity_argument_value(): | ||
with pytest.raises(ValueError) as excinfo: | ||
map_plant_capacity(scenario, ["solar"], disaggregation="renewables") | ||
assert "Unknown disaggregation method: renewables" in str(excinfo.value) |