Skip to content

Commit

Permalink
Adapt and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SabineHaas committed Jan 17, 2019
1 parent c6fe129 commit e180b2f
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions tests/test_wind_turbine.py
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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)

0 comments on commit e180b2f

Please sign in to comment.