Skip to content

Commit

Permalink
Add Test for Unbound Filter Form
Browse files Browse the repository at this point in the history
  • Loading branch information
Dean Pienaar committed Nov 1, 2018
1 parent 4f822c9 commit a405960
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ class View(FilterView):
self.assertEqual(message, expected)
self.assertEqual(len(recorded), 0)

def test_view_with_unbound_filter_form_returns_initial_queryset(self):
factory = RequestFactory()
request = factory.get(self.base_url)
queryset = Book.objects.filter(title='Snowcrash')
view = FilterView.as_view(model=Book, queryset=queryset)
response = view(request)
titles = [o.title for o in response.context_data['object_list']]

self.assertEqual(response.status_code, 200)
self.assertEqual(titles, ['Snowcrash'], )


class GenericFunctionalViewTests(GenericViewTestCase):
base_url = '/books-legacy/'
Expand Down

0 comments on commit a405960

Please sign in to comment.