def test_choices_boolean(self): """Test that the choices for a boolean filter include True and False. """ filter_spec = FilterSpec(_request('/test'), TestModel, 'someflag') choice_urls = [c.link for c in filter_spec.get_choices()] ok_('/test?' in choice_urls) ok_('/test?someflag=True' in choice_urls) ok_('/test?someflag=False' in choice_urls)
def test_choices_choice(self): """Test that choices for a choice filter include all available choices. """ filter_spec = FilterSpec(_request('/test'), TestModel, 'mychoice') choice_urls = [c.link for c in filter_spec.get_choices()] eq_(len(choice_urls), 3) ok_('/test?' in choice_urls) ok_('/test?mychoice=test1' in choice_urls) ok_('/test?mychoice=test2' in choice_urls)
def test_choices_relation(self): """Test that the choices for a relation filter include every related item. """ TestModelRel.objects.all().delete() a = TestModelRelFactory(value=False) b = TestModelRelFactory(value=True) filter_spec = FilterSpec(_request('/test'), TestModel, 'other') choice_urls = [c.link for c in filter_spec.get_choices()] eq_(len(choice_urls), 3) ok_('/test?' in choice_urls) ok_('/test?other=%s' % a.id in choice_urls) ok_('/test?other=%s' % b.id in choice_urls)