Skip to content

Commit e180b2f

Browse files
committed
Adapt and add tests
1 parent c6fe129 commit e180b2f

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

tests/test_wind_turbine.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
import pandas as pd
2-
from pandas.util.testing import assert_series_equal
31
import pytest
2+
import os
43

5-
from windpowerlib.wind_turbine import read_turbine_data, WindTurbine
4+
from windpowerlib.wind_turbine import (get_turbine_data_from_file, WindTurbine,
5+
get_turbine_types)
66

77
class TestWindTurbine:
88

99
def test_error_raising(self):
10+
source = os.path.join(os.path.dirname(__file__), '../example/data',
11+
'example_power_curves.csv')
1012
self.test_turbine_data = {'hub_height': 100,
1113
'rotor_diameter': 80,
1214
'name': 'turbine_not_in_file',
1315
'fetch_curve': 'power_curve',
14-
'data_source': 'example_power_curves.csv'}
15-
# Raise system exit
16+
'data_source': source}
17+
# Raise system exit due to turbine type not in file
1618
with pytest.raises(SystemExit):
1719
test_turbine = WindTurbine(**self.test_turbine_data)
1820

@@ -22,8 +24,17 @@ def test_error_raising(self):
2224
with pytest.raises(ValueError):
2325
test_turbine = WindTurbine(**self.test_turbine_data)
2426

27+
# Raise KeyError due to turbine type not in oedb
28+
self.test_turbine_data['fetch_curve'] = 'power_curve'
29+
self.test_turbine_data['data_source'] = 'oedb'
30+
with pytest.raises(KeyError):
31+
test_turbine = WindTurbine(**self.test_turbine_data)
32+
33+
2534
def test_read_turbine_data(self):
2635
# Raise FileNotFoundError due to missing
2736
with pytest.raises(FileNotFoundError):
28-
read_turbine_data(filename='not_existent')
37+
get_turbine_data_from_file(turbine_type='...', file_='not_existent') # todo test turbine type not found?
2938

39+
def test_get_turbine_types(self):
40+
get_turbine_types(print_out=False)

0 commit comments

Comments
 (0)