Skip to content

Commit 842d707

Browse files
committed
removed deprecated warnings from route function
1 parent 2550fc3 commit 842d707

File tree

2 files changed

+0
-69
lines changed

2 files changed

+0
-69
lines changed

ninja_extra/controllers/route/route_functions.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import inspect
2-
import warnings
32
from contextlib import contextmanager
43
from functools import wraps
54
from typing import TYPE_CHECKING, Any, Callable, Iterator, Optional, Tuple, cast
@@ -114,23 +113,6 @@ def as_view(
114113
as_view.get_route_function = lambda: self # type:ignore
115114
return as_view
116115

117-
def _process_view_function_result(self, result: Any) -> Any:
118-
"""
119-
This process any a returned value from view_func
120-
and creates an api response if a result is ControllerResponseSchema
121-
122-
deprecated:: 0.21.5
123-
This method is deprecated and will be removed in a future version.
124-
The result processing should be handled by the response handlers.
125-
"""
126-
warnings.warn(
127-
"_process_view_function_result() is deprecated and will be removed in a future version. "
128-
"The result processing should be handled by the response handlers.",
129-
DeprecationWarning,
130-
stacklevel=2,
131-
)
132-
return result
133-
134116
def _get_controller_instance(self) -> "ControllerBase":
135117
from ninja_extra.controllers.base import ModelControllerBase
136118

@@ -155,26 +137,6 @@ def _get_controller_instance(self) -> "ControllerBase":
155137

156138
return controller_instance
157139

158-
def get_route_execution_context(
159-
self, request: HttpRequest, *args: Any, **kwargs: Any
160-
) -> RouteContext:
161-
warnings.warn(
162-
"get_route_execution_context() is deprecated in favor of "
163-
"ninja_extra.controllers.route.context.get_route_execution_context()",
164-
DeprecationWarning,
165-
stacklevel=2,
166-
)
167-
168-
init_kwargs = {
169-
"permission_classes": self.route.permissions
170-
or self.api_controller.permission_classes,
171-
"request": request,
172-
"kwargs": kwargs,
173-
"args": args,
174-
}
175-
context = RouteContext(**init_kwargs) # type:ignore[arg-type]
176-
return context
177-
178140
@contextmanager
179141
def _prep_controller_route_execution(
180142
self, route_context: RouteContext, **kwargs: Any

tests/test_route.py

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from ninja_extra import api_controller, permissions, route
1010
from ninja_extra.constants import ROUTE_OBJECT
1111
from ninja_extra.context import (
12-
RouteContext,
1312
get_route_execution_context,
1413
)
1514
from ninja_extra.controllers import (
@@ -20,7 +19,6 @@
2019
from ninja_extra.controllers.base import get_route_functions
2120
from ninja_extra.controllers.utils import get_api_controller
2221
from ninja_extra.exceptions import PermissionDenied
23-
from ninja_extra.permissions import AllowAny
2422
from ninja_extra.reflect import reflect
2523

2624
from .schemas import UserSchema
@@ -320,22 +318,6 @@ def test_get_required_api_func_signature_return_filtered_signature(self):
320318
assert len(sig_parameter) == 1
321319
assert str(sig_parameter[0]).replace(" ", "") == "example_id:str"
322320

323-
def test_get_route_execution_context(self):
324-
route.get("")(self.api_func)
325-
route_object = reflect.get_metadata_or_raise_exception(
326-
ROUTE_OBJECT, self.api_func
327-
)
328-
route_function = RouteFunction(route_object, Mock())
329-
route_function.api_controller.permission_classes = [AllowAny]
330-
331-
route_context = route_function.get_route_execution_context(
332-
anonymous_request, "arg1", "arg2", extra="extra"
333-
)
334-
assert isinstance(route_context, RouteContext)
335-
expected_keywords = ("permission_classes", "request", "args", "kwargs")
336-
for key in expected_keywords:
337-
assert getattr(route_context, key)
338-
339321
def test_get_controller_instance_return_controller_instance(
340322
self, get_route_function
341323
):
@@ -348,19 +330,6 @@ def test_get_controller_instance_return_controller_instance(
348330
assert isinstance(controller_instance, SomeTestController)
349331
assert controller_instance.context is None
350332

351-
def test_process_view_function_result_return_tuple_or_input(
352-
self, get_route_function
353-
):
354-
route_function: RouteFunction = get_route_function(SomeTestController().example)
355-
mock_result = {"detail": "Some Message", "status_code": 302}
356-
response = route_function._process_view_function_result(mock_result)
357-
assert response == mock_result
358-
359-
mock_result = {"status": 302, "message": "Some Message"}
360-
response = route_function._process_view_function_result(mock_result)
361-
assert not isinstance(response, tuple)
362-
assert response == mock_result
363-
364333

365334
@pytest.mark.django_db
366335
class TestAPIControllerRoutePermission:

0 commit comments

Comments
 (0)