From 81dc1e066e5d0252ea54852a64893965ec856f99 Mon Sep 17 00:00:00 2001 From: Mladen Gibanica <11275336+mgcth@users.noreply.github.com> Date: Sat, 30 Mar 2024 15:09:37 +0100 Subject: [PATCH] Update some tests --- src/smhi/metfcts.py | 4 ++-- src/smhi/models/variable_model.py | 4 ++-- tests/unit/{test_unit_smhi.py => _test_unit_smhi.py} | 0 tests/unit/test_unit_metobs.py | 12 ++++++------ tests/unit/test_unit_strang.py | 8 ++++---- 5 files changed, 14 insertions(+), 14 deletions(-) rename tests/unit/{test_unit_smhi.py => _test_unit_smhi.py} (100%) diff --git a/src/smhi/metfcts.py b/src/smhi/metfcts.py index aaea4ac5..69f51b6f 100644 --- a/src/smhi/metfcts.py +++ b/src/smhi/metfcts.py @@ -4,7 +4,7 @@ from smhi.constants import METFCTS_PARAMETER_DESCRIPTIONS, METFCTS_URL from smhi.mesan import Mesan -from smhi.models.metfcts import ( +from smhi.models.metfcts_model import ( MetfctsApprovedTime, MetfctsMultiPointData, MetfctsParameters, @@ -12,7 +12,7 @@ MetfctsPolygon, MetfctsValidTime, ) -from smhi.models.variable import ( +from smhi.models.variable_model import ( ApprovedTime, MultiPointData, Parameters, diff --git a/src/smhi/models/variable_model.py b/src/smhi/models/variable_model.py index bdaf64aa..d2a17be9 100644 --- a/src/smhi/models/variable_model.py +++ b/src/smhi/models/variable_model.py @@ -2,7 +2,7 @@ from typing import TypeVar -from smhi.models.mesan import ( +from smhi.models.mesan_model import ( MesanApprovedTime, MesanMultiPointData, MesanParameters, @@ -10,7 +10,7 @@ MesanPolygon, MesanValidTime, ) -from smhi.models.metfcts import ( +from smhi.models.metfcts_model import ( MetfctsApprovedTime, MetfctsMultiPointData, MetfctsParameters, diff --git a/tests/unit/test_unit_smhi.py b/tests/unit/_test_unit_smhi.py similarity index 100% rename from tests/unit/test_unit_smhi.py rename to tests/unit/_test_unit_smhi.py diff --git a/tests/unit/test_unit_metobs.py b/tests/unit/test_unit_metobs.py index f3a691c8..8b0cb512 100644 --- a/tests/unit/test_unit_metobs.py +++ b/tests/unit/test_unit_metobs.py @@ -282,7 +282,7 @@ def test_unit_basemetobs_init(self): assert base.summary is None assert base.link is None - @patch("smhi.metobs.requests.get", return_value=MockResponse(200, None, None)) + @patch("smhi.utils.requests.get", return_value=MockResponse(200, None, None)) def test_unit_basemetobs_get_and_parse_request(self, mock_requests_get): """Unit test for BaseMetobs _get_and_parse_request method. @@ -346,7 +346,7 @@ class TestUnitVersions: """Unit tests for Versionss class.""" @pytest.mark.parametrize("data_type", [("json"), ("yaml"), ("xml"), (None)]) - @patch("smhi.metobs.requests.get") + @patch("smhi.utils.requests.get") def test_unit_versions_init(self, mock_requests_get, data_type, setup_versions): """Unit test for Parameters init method. @@ -391,7 +391,7 @@ class TestUnitParameters: ], ) @patch("smhi.metobs.Versions") - @patch("smhi.metobs.requests.get") + @patch("smhi.utils.requests.get") def test_unit_parameters_init( self, mock_requests_get, @@ -451,7 +451,7 @@ class TestUnitStations: ("1", "Lufttemperatur", None), ], ) - @patch("smhi.metobs.requests.get") + @patch("smhi.utils.requests.get") def test_unit_stations_init( self, mock_requests_get, @@ -516,7 +516,7 @@ class TestUnitPeriods: (1, "Akalla", "all", "json"), ], ) - @patch("smhi.metobs.requests.get") + @patch("smhi.utils.requests.get") def test_unit_periods_init( self, mock_requests_get, @@ -595,7 +595,7 @@ class TestUnitData: ("corrected-archive", "json"), ], ) - @patch("smhi.metobs.requests.get") + @patch("smhi.utils.requests.get") def test_unit_data_init( self, mock_requests_get, diff --git a/tests/unit/test_unit_strang.py b/tests/unit/test_unit_strang.py index 5f747c15..87d385b2 100644 --- a/tests/unit/test_unit_strang.py +++ b/tests/unit/test_unit_strang.py @@ -13,7 +13,7 @@ STRANG_PARAMETERS, STRANG_POINT_URL, ) -from smhi.models.strang import StrangParameter +from smhi.models.strang_model import StrangParameter from smhi.strang import Strang INPUT_DAILY_2020_01_01_2020_01_02 = [ @@ -410,11 +410,11 @@ def test_unit_strang_build_time_multipoint_url(self, time_interval, expected_url @patch("smhi.strang.Strang._parse_point_data") @patch("smhi.strang.logging.info") @patch( - "smhi.strang.requests.get", + "smhi.utils.requests.get", return_value=type( "MyClass", (object,), - {"status": True, "headers": "header", "content": "content"}, + {"status_code": 200, "headers": "header", "content": "content"}, )(), ) @patch( @@ -447,7 +447,7 @@ def test_unit_strang_get_and_load_data( mock_requests_get.return_value.status_code = status_expected data, headers, status = client._get_and_load_data(client.url, "parameter") - mock_requests_get.assert_called_once_with(client.url) + mock_requests_get.assert_called_once_with(client.url, timeout=200) if status == 200: mock_json_loads.assert_called_once_with(