Skip to content

Commit d0b0683

Browse files
author
Ryan P Kilby
authored
Add test for related error handling (#186)
1 parent c49c65b commit d0b0683

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/test_filtering.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,23 @@ class Meta:
387387
# should pass
388388
NoteFilter(GET, queryset=Note.objects.all(), request=object()).qs
389389

390+
def test_validation(self):
391+
class F(PostFilter):
392+
pk = filters.NumberFilter(name='id')
393+
394+
GET = {
395+
'note__author': 'foo',
396+
'pk': 'bar',
397+
}
398+
399+
f = F(GET, queryset=Post.objects.all())
400+
self.assertQuerysetEqual(f.qs, Post.objects.none())
401+
self.assertFalse(f.form.is_valid())
402+
403+
self.assertEqual(len(f.form.errors.keys()), 2)
404+
self.assertIn('note__author', f.form.errors)
405+
self.assertIn('pk', f.form.errors)
406+
390407

391408
class MiscTests(TestCase):
392409
def test_multiwidget_incompatibility(self):

0 commit comments

Comments
 (0)