2020
2121
2222@pytest .fixture
23- def mock_api_version (mocker : MockerFixture ) -> str :
23+ def current_api_version (mocker : MockerFixture ) -> str :
2424 """Fixture to mock the API_VERSION for testing purposes"""
2525 return "0.7.0"
2626
@@ -51,8 +51,14 @@ def test_changelog_entry_classes():
5151 assert deprecated_entry .entry_type == ChangelogType .DEPRECATED
5252 assert deprecated_entry .get_version () == Version ("0.7.0" )
5353 assert "Deprecated" in deprecated_entry .to_string ()
54+ assert "in *version 0.7.0*" in deprecated_entry .to_string ()
5455 assert "/v1/better-endpoint" in deprecated_entry .to_string ()
5556
57+ # Test DeprecatedEndpoint without version
58+ deprecated_no_version = DeprecatedEndpoint ("/v1/better-endpoint" )
59+ assert "Deprecated" in deprecated_no_version .to_string ()
60+ assert "in *version" not in deprecated_no_version .to_string ()
61+
5662 # Test RemovedEndpoint
5763 removed_entry = RemovedEndpoint ("0.9.0" , "Use the new endpoint instead" )
5864 assert removed_entry .entry_type == ChangelogType .REMOVED
@@ -114,7 +120,7 @@ def test_create_route_description():
114120 assert "Changed in *version 0.6.0*: Added authentication" in desc
115121
116122
117- def test_create_route_config_for_deprecated_endpoints (mock_api_version : str ) -> None :
123+ def test_create_route_config_for_deprecated_endpoints (current_api_version : str ) -> None :
118124 """Test route configuration for deprecated endpoints"""
119125 alternative_route = "/v1/new-endpoint"
120126 changelog = [
@@ -125,7 +131,7 @@ def test_create_route_config_for_deprecated_endpoints(mock_api_version: str) ->
125131 config = create_route_config (
126132 base_description = "This is a deprecated endpoint" ,
127133 changelog = changelog ,
128- current_version = Version (mock_api_version ),
134+ current_version = Version (current_api_version ),
129135 )
130136
131137 expected_config = {
@@ -141,18 +147,18 @@ def test_create_route_config_for_deprecated_endpoints(mock_api_version: str) ->
141147
142148
143149def test_create_route_config_for_to_be_released_endpoints (
144- mock_api_version : str ,
150+ current_api_version : str ,
145151) -> None :
146152 """Test route configuration for endpoints that will be released in future versions"""
147- future_version = f"{ int (Version (mock_api_version ).major ) + 1 } .0.0"
153+ future_version = f"{ int (Version (current_api_version ).major ) + 1 } .0.0"
148154 changelog = [
149155 NewEndpoint (future_version ),
150156 ]
151157
152158 config = create_route_config (
153159 base_description = f"This is a feature coming in version { future_version } " ,
154160 changelog = changelog ,
155- current_version = Version (mock_api_version ),
161+ current_version = Version (current_api_version ),
156162 )
157163
158164 expected_config = {
@@ -167,7 +173,7 @@ def test_create_route_config_for_to_be_released_endpoints(
167173 assert config == expected_config
168174
169175
170- def test_create_route_config_with_removal_notice (mock_api_version : str ) -> None :
176+ def test_create_route_config_with_removal_notice (current_api_version : str ) -> None :
171177 """Test route configuration with explicit removal notice in changelog"""
172178 removal_message = "Use the new endpoint instead"
173179 alternative_route = "/v1/better-endpoint"
@@ -181,12 +187,12 @@ def test_create_route_config_with_removal_notice(mock_api_version: str) -> None:
181187 config = create_route_config (
182188 base_description = "This endpoint will be removed in version 0.9.0" ,
183189 changelog = changelog ,
184- current_version = Version ( mock_api_version ) ,
190+ current_version = current_api_version ,
185191 )
186192
187193 expected_config = {
188194 "deprecated" : True ,
189- "include_in_schema" : True ,
195+ "include_in_schema" : False , # Changed from True to False due to REMOVED entry
190196 "description" : create_route_description (
191197 base = "This endpoint will be removed in version 0.9.0" ,
192198 changelog = changelog ,
@@ -196,14 +202,14 @@ def test_create_route_config_with_removal_notice(mock_api_version: str) -> None:
196202 assert config == expected_config
197203
198204
199- def test_create_route_config_with_regular_endpoint (mock_api_version : str ) -> None :
205+ def test_create_route_config_with_regular_endpoint (current_api_version : str ) -> None :
200206 """Test route configuration for a standard endpoint (not deprecated, not upcoming)"""
201207 changelog = [NewEndpoint ("0.5.0" )]
202208
203209 config = create_route_config (
204210 base_description = "This is a standard endpoint" ,
205211 changelog = changelog ,
206- current_version = mock_api_version ,
212+ current_version = current_api_version ,
207213 )
208214
209215 expected_config = {
@@ -218,7 +224,7 @@ def test_create_route_config_with_regular_endpoint(mock_api_version: str) -> Non
218224 assert config == expected_config
219225
220226
221- def test_create_route_config_with_mixed_changelog (mock_api_version : str ) -> None :
227+ def test_create_route_config_with_mixed_changelog (current_api_version : str ) -> None :
222228
223229 alternative_route = "/v1/better-endpoint"
224230 changelog = [
@@ -232,12 +238,12 @@ def test_create_route_config_with_mixed_changelog(mock_api_version: str) -> None
232238 config = create_route_config (
233239 base_description = "This endpoint has a complex history" ,
234240 changelog = changelog ,
235- current_version = mock_api_version ,
241+ current_version = current_api_version ,
236242 )
237243
238244 expected_config = {
239245 "deprecated" : True ,
240- "include_in_schema" : True ,
246+ "include_in_schema" : False , # Changed from True to False due to REMOVED entry
241247 "description" : create_route_description (
242248 base = "This endpoint has a complex history" ,
243249 changelog = changelog ,
@@ -247,11 +253,11 @@ def test_create_route_config_with_mixed_changelog(mock_api_version: str) -> None
247253 assert config == expected_config
248254
249255
250- def test_create_route_config_with_empty_changelog (mock_api_version : str ) -> None :
256+ def test_create_route_config_with_empty_changelog (current_api_version : str ) -> None :
251257
252258 config = create_route_config (
253259 base_description = "This endpoint has no changelog" ,
254- current_version = mock_api_version ,
260+ current_version = current_api_version ,
255261 )
256262
257263 expected_config = {
@@ -264,3 +270,15 @@ def test_create_route_config_with_empty_changelog(mock_api_version: str) -> None
264270 }
265271
266272 assert config == expected_config
273+
274+
275+ # Add a new test to explicitly verify the version display in deprecated endpoints
276+ def test_deprecated_endpoint_with_version ():
277+ """Test that DeprecatedEndpoint correctly displays the version information when available"""
278+ # With version
279+ deprecated_with_version = DeprecatedEndpoint ("/new/endpoint" , "0.8.0" )
280+ assert "in *version 0.8.0*" in deprecated_with_version .to_string ()
281+
282+ # Without version
283+ deprecated_without_version = DeprecatedEndpoint ("/new/endpoint" )
284+ assert "in *version" not in deprecated_without_version .to_string ()
0 commit comments