55# pylint: disable=unused-variable
66
77import pytest
8- from packaging .version import Version
9- from pytest_mock import MockerFixture
10- from simcore_service_api_server .api .routes ._constants import (
8+ from common_library .changelog import (
119 ChangedEndpoint ,
1210 ChangelogType ,
1311 DeprecatedEndpoint ,
1715 create_route_description ,
1816 validate_changelog ,
1917)
18+ from packaging .version import Version
19+ from pytest_mock import MockerFixture
2020
2121
2222@pytest .fixture
2323def mock_api_version (mocker : MockerFixture ) -> str :
2424 """Fixture to mock the API_VERSION for testing purposes"""
25- import simcore_service_api_server .api .routes ._constants
26-
27- mock_version = "0.7.0"
28- mocker .patch .object (
29- simcore_service_api_server .api .routes ._constants ,
30- "API_VERSION" ,
31- mock_version ,
32- )
33- return mock_version
25+ return "0.7.0"
3426
3527
3628def test_changelog_entry_types ():
@@ -122,7 +114,7 @@ def test_create_route_description():
122114 assert "Changed in *version 0.6.0*: Added authentication" in desc
123115
124116
125- def test_create_route_config_for_deprecated_endpoints () -> None :
117+ def test_create_route_config_for_deprecated_endpoints (mock_api_version : str ) -> None :
126118 """Test route configuration for deprecated endpoints"""
127119 alternative_route = "/v1/new-endpoint"
128120 changelog = [
@@ -133,6 +125,7 @@ def test_create_route_config_for_deprecated_endpoints() -> None:
133125 config = create_route_config (
134126 base_description = "This is a deprecated endpoint" ,
135127 changelog = changelog ,
128+ current_version = Version (mock_api_version ),
136129 )
137130
138131 expected_config = {
@@ -159,6 +152,7 @@ def test_create_route_config_for_to_be_released_endpoints(
159152 config = create_route_config (
160153 base_description = f"This is a feature coming in version { future_version } " ,
161154 changelog = changelog ,
155+ current_version = Version (mock_api_version ),
162156 )
163157
164158 expected_config = {
@@ -173,7 +167,7 @@ def test_create_route_config_for_to_be_released_endpoints(
173167 assert config == expected_config
174168
175169
176- def test_create_route_config_with_removal_notice () -> None :
170+ def test_create_route_config_with_removal_notice (mock_api_version : str ) -> None :
177171 """Test route configuration with explicit removal notice in changelog"""
178172 removal_message = "Use the new endpoint instead"
179173 alternative_route = "/v1/better-endpoint"
@@ -187,6 +181,7 @@ def test_create_route_config_with_removal_notice() -> None:
187181 config = create_route_config (
188182 base_description = "This endpoint will be removed in version 0.9.0" ,
189183 changelog = changelog ,
184+ current_version = Version (mock_api_version ),
190185 )
191186
192187 expected_config = {
@@ -201,13 +196,14 @@ def test_create_route_config_with_removal_notice() -> None:
201196 assert config == expected_config
202197
203198
204- def test_create_route_config_with_regular_endpoint () -> None :
199+ def test_create_route_config_with_regular_endpoint (mock_api_version : str ) -> None :
205200 """Test route configuration for a standard endpoint (not deprecated, not upcoming)"""
206201 changelog = [NewEndpoint ("0.5.0" )]
207202
208203 config = create_route_config (
209204 base_description = "This is a standard endpoint" ,
210205 changelog = changelog ,
206+ current_version = mock_api_version ,
211207 )
212208
213209 expected_config = {
@@ -222,19 +218,21 @@ def test_create_route_config_with_regular_endpoint() -> None:
222218 assert config == expected_config
223219
224220
225- def test_create_route_config_with_mixed_changelog () -> None :
226- """Test route configuration with a complex changelog containing multiple entries"""
221+ def test_create_route_config_with_mixed_changelog (mock_api_version : str ) -> None :
222+
227223 alternative_route = "/v1/better-endpoint"
228224 changelog = [
229225 NewEndpoint ("0.5.0" ),
230226 ChangedEndpoint ("0.6.0" , "Added authentication" ),
227+ ChangedEndpoint ("0.6.2" , "Fixed a bug" ),
231228 DeprecatedEndpoint (alternative_route ),
232229 RemovedEndpoint ("0.9.0" , "Use the new endpoint instead" ),
233230 ]
234231
235232 config = create_route_config (
236233 base_description = "This endpoint has a complex history" ,
237234 changelog = changelog ,
235+ current_version = mock_api_version ,
238236 )
239237
240238 expected_config = {
@@ -249,10 +247,11 @@ def test_create_route_config_with_mixed_changelog() -> None:
249247 assert config == expected_config
250248
251249
252- def test_create_route_config_with_empty_changelog () -> None :
253- """Test route configuration with an empty changelog"""
250+ def test_create_route_config_with_empty_changelog (mock_api_version : str ) -> None :
251+
254252 config = create_route_config (
255253 base_description = "This endpoint has no changelog" ,
254+ current_version = mock_api_version ,
256255 )
257256
258257 expected_config = {
0 commit comments