Skip to content

Commit

Permalink
Adjust test for local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
gutzbenj committed Jun 10, 2020
1 parent 0c7dded commit 97b03ed
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
8 changes: 3 additions & 5 deletions tests/test_data_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
from python_dwd.enumerations.period_type_enumeration import PeriodType
from python_dwd.data_collection import collect_dwd_data

# Create folder for storage test
test_folder = Path(Path(__file__).parent.absolute() / "dwd_data")
test_folder.mkdir(parents=True, exist_ok=True)

fixtures_dir = Path(__file__, "../").resolve().absolute() / "fixtures"

Expand Down Expand Up @@ -45,11 +48,6 @@
)
def test_collect_dwd_data():
""" Test for data collection """

# Create folder for storage test
test_folder = Path(Path(__file__).parent.absolute() / "dwd_data")
test_folder.mkdir(parents=True, exist_ok=True)

"""
1. Scenario
This scenario makes sure we take fresh data and write it to the given folder, thus we can run
Expand Down
24 changes: 22 additions & 2 deletions tests/test_data_storing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
import pandas as pd
import mock
from shutil import rmtree

from python_dwd.additionals.helpers import create_stationdata_dtype_mapping
from python_dwd.enumerations.parameter_enumeration import Parameter
Expand All @@ -11,6 +12,10 @@

from python_dwd.data_storing import store_dwd_data, restore_dwd_data, _build_local_store_key

# Create folder for storage test
test_folder = Path(Path(__file__).parent.absolute() / "dwd_data")
test_folder.mkdir(parents=True, exist_ok=True)

fixtures_dir = Path(__file__, "../").resolve().absolute() / "fixtures"

# Setting parameters for tests
Expand Down Expand Up @@ -71,14 +76,29 @@ def test_build_local_store_key():
"pandas.read_hdf",
mock.MagicMock(return_value=file)
)
def test_restore_dwd_data():
def test_store_dwd_data():
""" Tests for restore_dwd_data """
store_dwd_data(
station_data=file,
station_id=station_id,
parameter=parameter,
time_resolution=time_resolution,
period_type=period_type,
folder=test_folder
)

success, station_data = restore_dwd_data(
station_id=station_id,
parameter=parameter,
time_resolution=time_resolution,
period_type=period_type,
folder=""
folder=test_folder
)

assert success and station_data.equals(file)

# Remove storage folder
rmtree(test_folder)

# Have to place an assert afterwards to ensure that above function is executed
assert True

0 comments on commit 97b03ed

Please sign in to comment.