Skip to content

Commit 2aa195b

Browse files
committed
Add tests to improve coverage
1 parent 536dae0 commit 2aa195b

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/test_turbine_cluster_modelchain.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pytest
12
import pandas as pd
23
import numpy as np
34
from pandas.util.testing import assert_series_equal
@@ -187,3 +188,36 @@ def test_run_model_turbine_cluster(self):
187188
power_plant=test_cluster, **parameters)
188189
test_tc_mc.run_model(self.weather_df)
189190
assert_series_equal(test_tc_mc.power_output, power_output_exp)
191+
192+
def test_error_raising(self):
193+
194+
# Raise ValueError when aggregated wind farm power curve needs to be
195+
# calculated but turbine does not have a power curve
196+
test_turbine = {
197+
'hub_height': 100,
198+
'rotor_diameter': 98,
199+
'turbine_type': 'V90/2000',
200+
'power_coefficient_curve': True}
201+
test_farm = {'wind_turbine_fleet':
202+
[{'wind_turbine':
203+
wt.WindTurbine(**self.test_turbine),
204+
'number_of_turbines': 3},
205+
{'wind_turbine':
206+
wt.WindTurbine(**test_turbine),
207+
'number_of_turbines': 3}]}
208+
test_tc_mc = tc_mc.TurbineClusterModelChain(
209+
power_plant=wf.WindFarm(**test_farm))
210+
with pytest.raises(ValueError):
211+
test_tc_mc.run_model(self.weather_df)
212+
213+
# Raise ValueError when neither turbulence intensity nor roughness
214+
# length are provided to apply power curve smoothing with standard
215+
# deviation method 'turbulence_intensity'
216+
parameters = {'smoothing': True,
217+
'standard_deviation_method': 'turbulence_intensity'}
218+
test_tc_mc = tc_mc.TurbineClusterModelChain(
219+
power_plant=wf.WindFarm(**self.test_farm), **parameters)
220+
weather_df = self.weather_df.copy()
221+
weather_df.pop('roughness_length')
222+
with pytest.raises(ValueError):
223+
test_tc_mc.run_model(weather_df)

0 commit comments

Comments
 (0)