def test_invalid_sort(self): """ An invalid value for sort should not break clean. Regression test for an issue where a user was attempting to break Flicks by submitting a bunch of invalid values for sort. """ form = VideoSearchForm(self.request, {"query": "blah", "sort": "invalid"}) form.full_clean() eq_(form.is_valid(), False)
def test_clean_no_query(self): """ If no search query is specified, do not alter the sort value or choices. """ form = VideoSearchForm(self.request, {"region": NORTH_AMERICA, "sort": "title"}) form.full_clean() eq_(form.cleaned_data["sort"], "title") choice_values = zip(*form.fields["sort"].choices)[0] ok_("" in choice_values)
def test_invalid_sort(self): """ An invalid value for sort should not break clean. Regression test for an issue where a user was attempting to break Flicks by submitting a bunch of invalid values for sort. """ form = VideoSearchForm(self.request, { 'query': 'blah', 'sort': 'invalid' }) form.full_clean() eq_(form.is_valid(), False)
def test_clean_no_query(self): """ If no search query is specified, do not alter the sort value or choices. """ form = VideoSearchForm(self.request, { 'region': NORTH_AMERICA, 'sort': 'title' }) form.full_clean() eq_(form.cleaned_data['sort'], 'title') choice_values = zip(*form.fields['sort'].choices)[0] ok_('' in choice_values)
def test_clean_query(self): """ If a search query is specified, remove the random option from the sort choices and, if the sort is currently set to random, switch to title sort. """ form = VideoSearchForm(self.request, {"query": "blah", "sort": ""}) form.full_clean() eq_(form.cleaned_data["sort"], "title") choice_values = zip(*form.fields["sort"].choices)[0] ok_("" not in choice_values) # Check that sort is preserved if it is not random. form = VideoSearchForm(self.request, {"query": "blah", "sort": "popular"}) form.full_clean() eq_(form.cleaned_data["sort"], "popular") choice_values = zip(*form.fields["sort"].choices)[0] ok_("" not in choice_values)
def test_clean_query(self): """ If a search query is specified, remove the random option from the sort choices and, if the sort is currently set to random, switch to title sort. """ form = VideoSearchForm(self.request, {'query': 'blah', 'sort': ''}) form.full_clean() eq_(form.cleaned_data['sort'], 'title') choice_values = zip(*form.fields['sort'].choices)[0] ok_('' not in choice_values) # Check that sort is preserved if it is not random. form = VideoSearchForm(self.request, { 'query': 'blah', 'sort': 'popular' }) form.full_clean() eq_(form.cleaned_data['sort'], 'popular') choice_values = zip(*form.fields['sort'].choices)[0] ok_('' not in choice_values)