File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 1+ import sys
2+ import unittest
3+
14import pytest
25from django .test import TestCase
36
@@ -187,6 +190,20 @@ def test_action(request):
187190
188191 assert str (excinfo .value ) == "@action() missing required argument: 'detail'"
189192
193+ @unittest .skipIf (sys .version_info < (3 , 11 ), "HTTPMethod was added in Python 3.11" )
194+ def test_method_mapping_http_method (self ):
195+ from http import HTTPMethod
196+
197+ method_names = [getattr (HTTPMethod , name .upper ()) for name in APIView .http_method_names ]
198+
199+ @action (detail = False , methods = method_names )
200+ def test_action ():
201+ raise NotImplementedError
202+
203+ expected_mapping = {name : test_action .__name__ for name in APIView .http_method_names }
204+
205+ assert test_action .mapping == expected_mapping
206+
190207 def test_method_mapping_http_methods (self ):
191208 # All HTTP methods should be mappable
192209 @action (detail = False , methods = [])
You can’t perform that action at this time.
0 commit comments