def test_apply_filter(self): """Test that apply_filter correctly filters a queryset.""" ft = TestModelFactory(unimportant=5) filter_spec = FilterSpec(_request('/test?unimportant=5'), TestModel, 'unimportant') qs = TestModel.objects.all() new_qs = filter_spec.apply_filter(qs) ok_(ft in new_qs)
def test_apply_filter_no_value(self): """Test that apply_filter will not filter the queryset if there is no value in the URL. """ TestModelFactory(unimportant=6) filter_spec = FilterSpec(_request('/test'), TestModel, 'unimportant') qs = TestModel.objects.all() new_qs = filter_spec.apply_filter(qs) eq_(list(qs), list(new_qs))