Skip to content

Commit 6f80ebf

Browse files
committed
Move test to data tests
1 parent da1edb4 commit 6f80ebf

File tree

2 files changed

+28
-30
lines changed

2 files changed

+28
-30
lines changed

tests/test_data_handling.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
"""
55

66
import os
7+
import time
78
from datetime import datetime
8-
99
from shutil import copyfile
1010

1111
import pandas as pd
1212
import pytest
1313

14-
from windpowerlib.data import check_imported_data, check_data_integretiy
14+
from windpowerlib.data import (
15+
check_data_integrity, check_imported_data, get_turbine_types,
16+
store_turbine_data_from_oedb)
1517

1618

1719
class TestDataCheck:
@@ -58,7 +60,7 @@ def test_normal_data_check(self):
5860
def test_data_check_logging_warnings(self, caplog):
5961
self.df.loc["GE158/4800", "has_power_curve"] = True
6062
self.df.loc["GE100/2750", "has_cp_curve"] = True
61-
check_data_integretiy(self.df, min_pc_length=26)
63+
check_data_integrity(self.df, min_pc_length=26)
6264
assert "E48/800: power_curve is to short (25 values)" in caplog.text
6365
assert "GE158/4800: No power curve" in caplog.text
6466
assert "GE100/2750: No cp-curve but has_cp_curve" in caplog.text
@@ -75,3 +77,22 @@ def test_broken_pwr_curve(self):
7577
msg = "could not convert string to float"
7678
with pytest.raises(ValueError, match=msg):
7779
check_imported_data(self.df, self.filename, self.time_stamp)
80+
81+
def test_get_turbine_types(self, capsys):
82+
get_turbine_types()
83+
captured = capsys.readouterr()
84+
assert "Enercon" in captured.out
85+
get_turbine_types("oedb", print_out=False, filter_=False)
86+
msg = "`turbine_library` is 'wrong' but must be 'local' or 'oedb'."
87+
with pytest.raises(ValueError, match=msg):
88+
get_turbine_types("wrong")
89+
90+
def test_store_turbine_data_from_oedb(self):
91+
store_turbine_data_from_oedb()
92+
93+
def test_wrong_url_load_turbine_data(self):
94+
"""Load turbine data from oedb."""
95+
with pytest.raises(
96+
ConnectionError, match="Database connection not successful"
97+
):
98+
store_turbine_data_from_oedb("wrong_schema")

tests/test_wind_turbine.py

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@
55
SPDX-License-Identifier: MIT
66
"""
77

8-
import pytest
98
import os
10-
from windpowerlib.tools import WindpowerlibUserWarning
119

12-
from windpowerlib.wind_turbine import (
13-
get_turbine_data_from_file,
14-
WindTurbine,
15-
WindTurbineGroup,
16-
)
10+
import pytest
1711

18-
from windpowerlib.data import store_turbine_data_from_oedb, get_turbine_types
12+
from windpowerlib.tools import WindpowerlibUserWarning
13+
from windpowerlib.wind_turbine import (
14+
WindTurbine, WindTurbineGroup, get_turbine_data_from_file)
1915

2016

2117
class TestWindTurbine:
@@ -39,25 +35,6 @@ def test_get_turbine_data_from_file(self):
3935
with pytest.raises(FileNotFoundError):
4036
get_turbine_data_from_file(turbine_type="...", path="not_existent")
4137

42-
def test_get_turbine_types(self, capsys):
43-
get_turbine_types()
44-
captured = capsys.readouterr()
45-
assert "Enercon" in captured.out
46-
get_turbine_types("oedb", print_out=False, filter_=False)
47-
msg = "`turbine_library` is 'wrong' but must be 'local' or 'oedb'."
48-
with pytest.raises(ValueError, match=msg):
49-
get_turbine_types("wrong")
50-
51-
def test_store_turbine_data_from_oedb(self):
52-
store_turbine_data_from_oedb()
53-
54-
def test_wrong_url_load_turbine_data(self):
55-
"""Load turbine data from oedb."""
56-
with pytest.raises(
57-
ConnectionError, match="Database connection not successful"
58-
):
59-
store_turbine_data_from_oedb("wrong_schema")
60-
6138
@pytest.mark.filterwarnings("ignore:The WindTurbine")
6239
def test_string_representation_of_wind_turbine(self):
6340
assert "Wind turbine: ['hub height=120 m'" in repr(WindTurbine(120))

0 commit comments

Comments
 (0)