Skip to content

Commit

Permalink
add a test to make sure tools functions actually get called
Browse files Browse the repository at this point in the history
  • Loading branch information
crccheck committed Oct 20, 2012
1 parent e20748d commit 892a838
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions example_project/test_app/tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from django.test import TestCase

from example_project.polls.models import Choice


class LoggedInTestCase(TestCase):
def setUp(self):
Expand All @@ -19,6 +21,15 @@ def test_configured_mixin_works(self):
self.assertEqual(response.status_code, 200)
self.assertIn('objectactions', response.context_data)

def test_tool_func_gets_executed(self):
c = Choice.objects.get(pk=1)
votes = c.votes
response = self.client.get('/admin/polls/choice/1/tools/increment_vote/')
self.assertEqual(response.status_code, 302)
self.assertTrue(response['location'].endswith('/admin/polls/choice/1/'))
c = Choice.objects.get(pk=1)
self.assertEqual(c.votes, votes + 1)

def test_tool_can_return_httpresponse(self):
# we know this url works because of fixtures
url = 'http://localhost:8000/admin/polls/choice/2/tools/edit_poll/'
Expand Down

0 comments on commit 892a838

Please sign in to comment.