|
16 | 16 |
|
17 | 17 | class TestWindTurbine: |
18 | 18 |
|
| 19 | + @classmethod |
| 20 | + def setup_class(cls): |
| 21 | + """Setup default values""" |
| 22 | + cls.source = os.path.join(os.path.dirname(__file__), '../example/data') |
| 23 | + |
19 | 24 | def test_warning(self, recwarn): |
20 | | - source = os.path.join(os.path.dirname(__file__), '../example/data') |
21 | 25 | test_turbine_data = {'hub_height': 100, |
22 | 26 | 'rotor_diameter': 80, |
23 | 27 | 'turbine_type': 'turbine_not_in_file', |
24 | | - 'path': source} |
| 28 | + 'path': self.source} |
25 | 29 | assert(WindTurbine(**test_turbine_data).power_curve is None) |
26 | 30 | assert recwarn.pop(WindpowerlibUserWarning) |
27 | 31 |
|
@@ -50,3 +54,27 @@ def test_wrong_url_load_turbine_data(self): |
50 | 54 | @pytest.mark.filterwarnings("ignore:The WindTurbine") |
51 | 55 | def test_string_representation_of_wind_turbine(self): |
52 | 56 | assert "Wind turbine: ['hub height=120 m'" in repr(WindTurbine(120)) |
| 57 | + |
| 58 | + def test_to_group_method(self): |
| 59 | + example_turbine = { |
| 60 | + 'hub_height': 100, |
| 61 | + 'rotor_diameter': 70, |
| 62 | + 'turbine_type': 'DUMMY 3', |
| 63 | + 'path': self.source} |
| 64 | + e_t_1 = WindTurbine(**example_turbine) |
| 65 | + assert(isinstance(e_t_1.to_group(5), dict)) |
| 66 | + assert(e_t_1.to_group(5)['number_of_turbines'] == 5) |
| 67 | + assert(e_t_1.to_group(number_turbines=5)['number_of_turbines'] == 5) |
| 68 | + assert(e_t_1.to_group(total_capacity=3e6)['number_of_turbines'] == 2.0) |
| 69 | + |
| 70 | + def test_wrongly_defined_to_group_method(self): |
| 71 | + example_turbine = { |
| 72 | + 'hub_height': 100, |
| 73 | + 'rotor_diameter': 70, |
| 74 | + 'turbine_type': 'DUMMY 3', |
| 75 | + 'path': self.source} |
| 76 | + e_t_1 = WindTurbine(**example_turbine) |
| 77 | + with pytest.raises(ValueError, |
| 78 | + match="The 'number' and the 'total_capacity" |
| 79 | + " parameter are mutually exclusive."): |
| 80 | + e_t_1.to_group(5, 3000) |
0 commit comments