@@ -13,6 +13,15 @@ def list(self, request, *args, **kwargs):
13
13
return Response ({'ACTION' : 'LIST' })
14
14
15
15
16
+ class InstanceViewSet (GenericViewSet ):
17
+
18
+ def dispatch (self , request , * args , ** kwargs ):
19
+ return self .dummy (request , * args , ** kwargs )
20
+
21
+ def dummy (self , request , * args , ** kwargs ):
22
+ return Response ({'view' : self })
23
+
24
+
16
25
class InitializeViewSetsTestCase (TestCase ):
17
26
def test_initialize_view_set_with_actions (self ):
18
27
request = factory .get ('/' , '' , content_type = 'application/json' )
@@ -42,3 +51,17 @@ def test_initialize_view_set_with_empty_actions(self):
42
51
"For example `.as_view({'get': 'list'})`" )
43
52
else :
44
53
self .fail ("actions must not be empty." )
54
+
55
+ def test_args_kwargs_request_action_map_on_self (self ):
56
+ """
57
+ Test a view only has args, kwargs, request, action_map
58
+ once `as_view` has been called.
59
+ """
60
+ bare_view = InstanceViewSet ()
61
+ view = InstanceViewSet .as_view (actions = {
62
+ 'get' : 'dummy' ,
63
+ })(factory .get ('/' )).data ['view' ]
64
+
65
+ for attribute in ('args' , 'kwargs' , 'request' , 'action_map' ):
66
+ self .assertNotIn (attribute , dir (bare_view ))
67
+ self .assertIn (attribute , dir (view ))
0 commit comments