2525 RouteFunction ,
2626 RouteInvalidParameterException ,
2727)
28- from ninja_extra .controllers .base import get_route_functions
28+ from ninja_extra .controllers .base import get_all_controller_route_function
2929from ninja_extra .controllers .route .context import RouteContext
3030from ninja_extra .exceptions import PermissionDenied
3131from ninja_extra .permissions import AllowAny
@@ -77,6 +77,10 @@ def example_delete(self, ex_id: str):
7777 def example_list_create (self , ex_id : str ):
7878 pass
7979
80+ @http_post ("/example/operation-id" , operation_id = "example_post_operation_id" )
81+ def example_post_operation_id (self ):
82+ pass
83+
8084
8185class TestControllerRoute :
8286 @pytest .mark .parametrize (
@@ -95,8 +99,10 @@ def test_api_controller_builds_accurate_operations_list(
9599 assert len (path_view .operations ) == operation_count
96100
97101 def test_controller_route_should_have_an_operation (self ):
98- for route_func in get_route_functions (SomeTestController ):
99- path_view = SomeTestController .get_path_operations ().get (str (route_func ))
102+ for route_func in get_all_controller_route_function (SomeTestController ):
103+ path_view = SomeTestController .get_api_controller ().path_operations .get (
104+ str (route_func )
105+ )
100106 operations = list (
101107 filter (
102108 lambda n : n .operation_id
@@ -105,6 +111,8 @@ def test_controller_route_should_have_an_operation(self):
105111 )
106112 )
107113 assert len (operations ) == 1
114+ if str (route_func ) == "/example/operation-id" :
115+ assert operations [0 ].operation_id == "example_post_operation_id"
108116 assert route_func .route .route_params .methods == operations [0 ].methods
109117
110118 def test_controller_route_should_right_view_func_type (self ):
0 commit comments