From 89fd79f6244b1c48c29fbf3ad4110dc93ee0ae39 Mon Sep 17 00:00:00 2001 From: leufen1 <l.leufen@fz-juelich.de> Date: Fri, 18 Dec 2020 11:06:39 +0100 Subject: [PATCH] moved some files and testing routines, finished tests for path config /close #237 --- test/test_configuration/test_join_settings.py | 25 +++++++++++++++++++ test/test_configuration/test_path_config.py | 4 +++ test/{ => test_helpers}/test_join.py | 8 ------ test/{ => test_helpers}/test_statistics.py | 0 4 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 test/test_configuration/test_join_settings.py rename test/{ => test_helpers}/test_join.py (97%) rename test/{ => test_helpers}/test_statistics.py (100%) diff --git a/test/test_configuration/test_join_settings.py b/test/test_configuration/test_join_settings.py new file mode 100644 index 00000000..8d977f45 --- /dev/null +++ b/test/test_configuration/test_join_settings.py @@ -0,0 +1,25 @@ +from mlair.configuration.join_settings import join_settings + +import pytest + + +class TestJoinSettings: + + def test_no_args(self): + url, headers = join_settings() + assert url == 'https://join.fz-juelich.de/services/rest/surfacedata/' + assert headers == {} + + def test_daily(self): + url, headers = join_settings("daily") + assert url == 'https://join.fz-juelich.de/services/rest/surfacedata/' + assert headers == {} + + def test_hourly(self): + url, headers = join_settings("hourly") + assert "Authorization" in headers.keys() + + def test_unknown_sampling(self): + with pytest.raises(NameError) as e: + join_settings("monthly") + assert "Given sampling monthly is not supported, choose from either daily or hourly sampling" in e.value.args[0] diff --git a/test/test_configuration/test_path_config.py b/test/test_configuration/test_path_config.py index 846f252e..fb8a2b19 100644 --- a/test/test_configuration/test_path_config.py +++ b/test/test_configuration/test_path_config.py @@ -27,6 +27,10 @@ class TestPrepareHost: def test_prepare_host_unknown(self, mock_user, mock_host): assert prepare_host() == os.path.join(os.path.abspath(os.getcwd()), 'data') + def test_prepare_host_given_path(self): + path = os.path.join(os.path.abspath(os.getcwd()), 'data') + assert prepare_host(data_path=path) == path + @mock.patch("getpass.getuser", return_value="zombie21") @mock.patch("mlair.configuration.path_config.check_path_and_create", side_effect=PermissionError) @mock.patch("os.path.exists", return_value=False) diff --git a/test/test_join.py b/test/test_helpers/test_join.py similarity index 97% rename from test/test_join.py rename to test/test_helpers/test_join.py index 850571e3..e903669b 100644 --- a/test/test_join.py +++ b/test/test_helpers/test_join.py @@ -7,14 +7,6 @@ from mlair.helpers.join import _save_to_pandas, _correct_stat_name, _lower_list, from mlair.configuration.join_settings import join_settings -class TestJoinUrlBase: - - def test_url(self): - url, headers = join_settings() - assert url == 'https://join.fz-juelich.de/services/rest/surfacedata/' - assert headers == {} - - class TestDownloadJoin: def test_download_single_var(self): diff --git a/test/test_statistics.py b/test/test_helpers/test_statistics.py similarity index 100% rename from test/test_statistics.py rename to test/test_helpers/test_statistics.py -- GitLab