Skip to content

Commit

Permalink
Add test for new example
Browse files Browse the repository at this point in the history
  • Loading branch information
SabineHaas committed Dec 13, 2018
1 parent c450e39 commit cd01074
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions example/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import nbformat
import sys
from example import basic_example as be
from example import further_example as fe
from numpy.testing import assert_allclose
import pytest

Expand All @@ -21,6 +22,21 @@ def test_basic_example_flh(self):
assert_allclose(1882.7567, (my_turbine.power_output.sum() /
my_turbine.nominal_power), 0.01)

def test_further_example_flh(self):
# tests full load hours
weather = be.get_weather_data('weather.csv')
my_turbine, e126 = be.initialise_wind_turbines()
example_farm, example_farm_2 = fe.initialise_wind_farms(my_turbine,
e126)
example_cluster = fe.initialise_wind_turbine_cluster(example_farm,
example_farm_2)
fe.calculate_power_output(weather, example_farm, example_cluster)
assert_allclose(1586.23527, (example_farm.power_output.sum() /
example_farm.installed_power), 0.01)
example_cluster.installed_power = example_cluster.get_installed_power()
assert_allclose(1813.66122, (example_cluster.power_output.sum() /
example_cluster.installed_power), 0.01)

def _notebook_run(self, path):
"""
Execute a notebook via nbconvert and collect output.
Expand Down Expand Up @@ -49,3 +65,10 @@ def test_basic_example_ipynb(self):
nb, errors = self._notebook_run(
os.path.join(dir_path, 'basic_example.ipynb'))
assert errors == []

@pytest.mark.skipif(sys.version_info < (3, 6), reason="requires python3.6")
def test_further_example_ipynb(self):
dir_path = os.path.dirname(os.path.realpath(__file__))
nb, errors = self._notebook_run(
os.path.join(dir_path, 'further_example.ipynb'))
assert errors == []

0 comments on commit cd01074

Please sign in to comment.