@@ -21,25 +21,25 @@ def test_action_on_a_model_with_uuid_pk_works(self):
2121 action_url = "/admin/polls/comment/{0}/actions/hodor/" .format (comment .pk )
2222 # sanity check that url has a uuid
2323 self .assertIn ("-" , action_url )
24- response = self .client .get (action_url )
24+ response = self .client .post (action_url )
2525 self .assertRedirects (response , comment_url )
2626
27- @patch ("django_object_actions.utils.ChangeActionView.get " )
27+ @patch ("django_object_actions.utils.ChangeActionView.post " )
2828 def test_action_on_a_model_with_arbitrary_pk_works (self , mock_view ):
2929 mock_view .return_value = HttpResponse ()
3030 action_url = "/admin/polls/comment/{0}/actions/hodor/" .format (" i am a pk " )
3131
32- self .client .get (action_url )
32+ self .client .post (action_url )
3333
3434 self .assertTrue (mock_view .called )
3535 self .assertEqual (mock_view .call_args [1 ]["pk" ], " i am a pk " )
3636
37- @patch ("django_object_actions.utils.ChangeActionView.get " )
37+ @patch ("django_object_actions.utils.ChangeActionView.post " )
3838 def test_action_on_a_model_with_slash_in_pk_works (self , mock_view ):
3939 mock_view .return_value = HttpResponse ()
4040 action_url = "/admin/polls/comment/{0}/actions/hodor/" .format ("pk/slash" )
4141
42- self .client .get (action_url )
42+ self .client .post (action_url )
4343
4444 self .assertTrue (mock_view .called )
4545 self .assertEqual (mock_view .call_args [1 ]["pk" ], "pk/slash" )
@@ -55,7 +55,7 @@ def test_action_on_a_model_with_complex_id(self):
5555 quote (related_data .pk )
5656 )
5757
58- response = self .client .get (action_url )
58+ response = self .client .post (action_url )
5959 self .assertNotEqual (response .status_code , 404 )
6060 self .assertRedirects (response , related_data_url )
6161
@@ -76,12 +76,12 @@ def test_changelist_template_context(self):
7676
7777 def test_changelist_action_view (self ):
7878 url = "/admin/polls/choice/actions/delete_all/"
79- response = self .client .get (url )
79+ response = self .client .post (url )
8080 self .assertRedirects (response , "/admin/polls/choice/" )
8181
8282 def test_changelist_nonexistent_action (self ):
8383 url = "/admin/polls/choice/actions/xyzzy/"
84- response = self .client .get (url )
84+ response = self .client .post (url )
8585 self .assertEqual (response .status_code , 404 )
8686
8787 def test_get_changelist_can_remove_action (self ):
@@ -94,13 +94,23 @@ def test_get_changelist_can_remove_action(self):
9494 response = self .client .get (admin_change_url )
9595 self .assertIn (action_url , response .rendered_content )
9696
97- response = self .client .get (action_url ) # Click on the button
97+ response = self .client .post (action_url ) # Click on the button
9898 self .assertRedirects (response , admin_change_url )
9999
100100 # button is not in the admin anymore
101101 response = self .client .get (admin_change_url )
102102 self .assertNotIn (action_url , response .rendered_content )
103103
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+
104114
105115class ChangeListTests (LoggedInTestCase ):
106116 def test_changelist_template_context (self ):
@@ -122,5 +132,5 @@ def test_redirect_back_from_secondary_admin(self):
122132 action_url = "/support/polls/poll/1/actions/question_mark/"
123133 self .assertTrue (admin_change_url .startswith ("/support/" ))
124134
125- response = self .client .get (action_url )
135+ response = self .client .post (action_url )
126136 self .assertRedirects (response , admin_change_url )
0 commit comments