File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import sys
2+
13import pytest
24from django .test import TestCase
35
@@ -187,6 +189,20 @@ def test_action(request):
187189
188190 assert str (excinfo .value ) == "@action() missing required argument: 'detail'"
189191
192+ @pytest .mark .skipif (sys .version_info < (3 , 11 ), reason = "HTTPMethod was added in Python 3.11" )
193+ def test_method_mapping_http_method (self ):
194+ from http import HTTPMethod
195+
196+ method_names = [getattr (HTTPMethod , name .upper ()) for name in APIView .http_method_names ]
197+
198+ @action (detail = False , methods = method_names )
199+ def test_action ():
200+ raise NotImplementedError
201+
202+ expected_mapping = {name : test_action .__name__ for name in APIView .http_method_names }
203+
204+ assert test_action .mapping == expected_mapping
205+
190206 def test_method_mapping_http_methods (self ):
191207 # All HTTP methods should be mappable
192208 @action (detail = False , methods = [])
You can’t perform that action at this time.
0 commit comments