diff --git a/tests/test_wind_turbine.py b/tests/test_wind_turbine.py index d6b49e6c..86af8c2b 100644 --- a/tests/test_wind_turbine.py +++ b/tests/test_wind_turbine.py @@ -1,18 +1,20 @@ -import pandas as pd -from pandas.util.testing import assert_series_equal import pytest +import os -from windpowerlib.wind_turbine import read_turbine_data, WindTurbine +from windpowerlib.wind_turbine import (get_turbine_data_from_file, WindTurbine, + get_turbine_types) class TestWindTurbine: def test_error_raising(self): + source = os.path.join(os.path.dirname(__file__), '../example/data', + 'example_power_curves.csv') self.test_turbine_data = {'hub_height': 100, 'rotor_diameter': 80, 'name': 'turbine_not_in_file', 'fetch_curve': 'power_curve', - 'data_source': 'example_power_curves.csv'} - # Raise system exit + 'data_source': source} + # Raise system exit due to turbine type not in file with pytest.raises(SystemExit): test_turbine = WindTurbine(**self.test_turbine_data) @@ -22,8 +24,17 @@ def test_error_raising(self): with pytest.raises(ValueError): test_turbine = WindTurbine(**self.test_turbine_data) + # Raise KeyError due to turbine type not in oedb + self.test_turbine_data['fetch_curve'] = 'power_curve' + self.test_turbine_data['data_source'] = 'oedb' + with pytest.raises(KeyError): + test_turbine = WindTurbine(**self.test_turbine_data) + + def test_read_turbine_data(self): # Raise FileNotFoundError due to missing with pytest.raises(FileNotFoundError): - read_turbine_data(filename='not_existent') + get_turbine_data_from_file(turbine_type='...', file_='not_existent') # todo test turbine type not found? + def test_get_turbine_types(self): + get_turbine_types(print_out=False)