@@ -21,25 +21,25 @@ def test_action_on_a_model_with_uuid_pk_works(self):
21
21
action_url = "/admin/polls/comment/{0}/actions/hodor/" .format (comment .pk )
22
22
# sanity check that url has a uuid
23
23
self .assertIn ("-" , action_url )
24
- response = self .client .get (action_url )
24
+ response = self .client .post (action_url )
25
25
self .assertRedirects (response , comment_url )
26
26
27
- @patch ("django_object_actions.utils.ChangeActionView.get " )
27
+ @patch ("django_object_actions.utils.ChangeActionView.post " )
28
28
def test_action_on_a_model_with_arbitrary_pk_works (self , mock_view ):
29
29
mock_view .return_value = HttpResponse ()
30
30
action_url = "/admin/polls/comment/{0}/actions/hodor/" .format (" i am a pk " )
31
31
32
- self .client .get (action_url )
32
+ self .client .post (action_url )
33
33
34
34
self .assertTrue (mock_view .called )
35
35
self .assertEqual (mock_view .call_args [1 ]["pk" ], " i am a pk " )
36
36
37
- @patch ("django_object_actions.utils.ChangeActionView.get " )
37
+ @patch ("django_object_actions.utils.ChangeActionView.post " )
38
38
def test_action_on_a_model_with_slash_in_pk_works (self , mock_view ):
39
39
mock_view .return_value = HttpResponse ()
40
40
action_url = "/admin/polls/comment/{0}/actions/hodor/" .format ("pk/slash" )
41
41
42
- self .client .get (action_url )
42
+ self .client .post (action_url )
43
43
44
44
self .assertTrue (mock_view .called )
45
45
self .assertEqual (mock_view .call_args [1 ]["pk" ], "pk/slash" )
@@ -55,7 +55,7 @@ def test_action_on_a_model_with_complex_id(self):
55
55
quote (related_data .pk )
56
56
)
57
57
58
- response = self .client .get (action_url )
58
+ response = self .client .post (action_url )
59
59
self .assertNotEqual (response .status_code , 404 )
60
60
self .assertRedirects (response , related_data_url )
61
61
@@ -76,12 +76,12 @@ def test_changelist_template_context(self):
76
76
77
77
def test_changelist_action_view (self ):
78
78
url = "/admin/polls/choice/actions/delete_all/"
79
- response = self .client .get (url )
79
+ response = self .client .post (url )
80
80
self .assertRedirects (response , "/admin/polls/choice/" )
81
81
82
82
def test_changelist_nonexistent_action (self ):
83
83
url = "/admin/polls/choice/actions/xyzzy/"
84
- response = self .client .get (url )
84
+ response = self .client .post (url )
85
85
self .assertEqual (response .status_code , 404 )
86
86
87
87
def test_get_changelist_can_remove_action (self ):
@@ -94,13 +94,23 @@ def test_get_changelist_can_remove_action(self):
94
94
response = self .client .get (admin_change_url )
95
95
self .assertIn (action_url , response .rendered_content )
96
96
97
- response = self .client .get (action_url ) # Click on the button
97
+ response = self .client .post (action_url ) # Click on the button
98
98
self .assertRedirects (response , admin_change_url )
99
99
100
100
# button is not in the admin anymore
101
101
response = self .client .get (admin_change_url )
102
102
self .assertNotIn (action_url , response .rendered_content )
103
103
104
+ def test_changelist_get_method_action_view (self ):
105
+ url = "/admin/polls/choice/actions/delete_all/"
106
+ response = self .client .get (url )
107
+ self .assertEqual (response .status_code , 405 )
108
+
109
+ def test_changelist_get_method_nonexistent_action (self ):
110
+ url = "/admin/polls/choice/actions/xyzzy/"
111
+ response = self .client .get (url )
112
+ self .assertEqual (response .status_code , 405 )
113
+
104
114
105
115
class ChangeListTests (LoggedInTestCase ):
106
116
def test_changelist_template_context (self ):
@@ -122,5 +132,5 @@ def test_redirect_back_from_secondary_admin(self):
122
132
action_url = "/support/polls/poll/1/actions/question_mark/"
123
133
self .assertTrue (admin_change_url .startswith ("/support/" ))
124
134
125
- response = self .client .get (action_url )
135
+ response = self .client .post (action_url )
126
136
self .assertRedirects (response , admin_change_url )
0 commit comments