4
4
from __future__ import unicode_literals
5
5
6
6
from django .core .urlresolvers import reverse
7
+ from django .http import HttpResponse
8
+ from mock import patch
7
9
8
10
from .tests import LoggedInTestCase
9
11
from example_project .polls .factories import CommentFactory , PollFactory
@@ -19,6 +21,26 @@ def test_action_on_a_model_with_uuid_pk_works(self):
19
21
response = self .client .get (action_url )
20
22
self .assertRedirects (response , comment_url )
21
23
24
+ @patch ('django_object_actions.utils.ChangeActionView.get' )
25
+ def test_action_on_a_model_with_arbitrary_pk_works (self , mock_view ):
26
+ mock_view .return_value = HttpResponse ()
27
+ action_url = '/admin/polls/comment/{0}/actions/hodor/' .format (' i am a pk ' )
28
+
29
+ self .client .get (action_url )
30
+
31
+ self .assertTrue (mock_view .called )
32
+ self .assertEqual (mock_view .call_args [1 ]['pk' ], ' i am a pk ' )
33
+
34
+ @patch ('django_object_actions.utils.ChangeActionView.get' )
35
+ def test_action_on_a_model_with_slash_in_pk_works (self , mock_view ):
36
+ mock_view .return_value = HttpResponse ()
37
+ action_url = '/admin/polls/comment/{0}/actions/hodor/' .format ('pk/slash' )
38
+
39
+ self .client .get (action_url )
40
+
41
+ self .assertTrue (mock_view .called )
42
+ self .assertEqual (mock_view .call_args [1 ]['pk' ], 'pk/slash' )
43
+
22
44
23
45
class ChangeTests (LoggedInTestCase ):
24
46
def test_buttons_load (self ):
0 commit comments