44from __future__ import unicode_literals
55
66from django .core .urlresolvers import reverse
7+ from django .http import HttpResponse
8+ from mock import patch
79
810from .tests import LoggedInTestCase
911from example_project .polls .factories import CommentFactory , PollFactory
@@ -19,6 +21,26 @@ def test_action_on_a_model_with_uuid_pk_works(self):
1921 response = self .client .get (action_url )
2022 self .assertRedirects (response , comment_url )
2123
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+
2244
2345class ChangeTests (LoggedInTestCase ):
2446 def test_buttons_load (self ):
0 commit comments