Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Add unit test for get_context_data in RandomTasksView
Browse files Browse the repository at this point in the history
  • Loading branch information
bobsilverberg authored and Michael Kelly committed Mar 24, 2014
1 parent 2cf70cb commit b84ac8f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions oneanddone/tasks/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,17 @@ def test_feedback_not_your_attempt(self):

with self.assertRaises(Http404):
self.view.dispatch(request, pk=attempt.pk)


class RandomTasksViewTests(TestCase):
def setUp(self):
self.view = views.RandomTasksView()

def test_get_context_data_returns_slice(self):
"""
A subset of 5 items should be returned when Random tasks are viewed.
"""
with patch('oneanddone.tasks.views.generic.ListView.get_context_data') as get_context_data:
get_context_data.return_value = {'object_list': [i for i in range(0, 10)]}
ctx = self.view.get_context_data()
eq_(len(ctx['random_task_list']), 5)

0 comments on commit b84ac8f

Please sign in to comment.