|
22 | 22 | NoteFilterWithRelatedAll, |
23 | 23 | NoteFilterWithRelatedAllDifferentFilterName, |
24 | 24 | PostFilterWithRelated, |
25 | | - # PostFilterWithMethod, |
| 25 | + PostFilterWithMethod, |
26 | 26 | CoverFilterWithRelatedMethodFilter, |
27 | 27 | CoverFilterWithRelated, |
28 | 28 | # PageFilterWithRelated, |
@@ -345,11 +345,20 @@ def generateTestData(cls): |
345 | 345 | note2 = Note.objects.create(title="Test 2", content="Test content 2", author=user) |
346 | 346 |
|
347 | 347 | post1 = Post.objects.create(note=note1, content="Test content in post 1") |
348 | | - post2 = Post.objects.create(note=note2, content="Test content in post 4", date_published=datetime.date.today()) |
| 348 | + post2 = Post.objects.create(note=note2, content="Test content in post 2", date_published=datetime.date.today()) |
349 | 349 |
|
350 | 350 | Cover.objects.create(post=post1, comment="Cover 1") |
351 | 351 | Cover.objects.create(post=post2, comment="Cover 2") |
352 | 352 |
|
| 353 | + def test_method_filter(self): |
| 354 | + GET = { |
| 355 | + 'is_published': 'true' |
| 356 | + } |
| 357 | + filterset = PostFilterWithMethod(GET, queryset=Post.objects.all()) |
| 358 | + results = list(filterset) |
| 359 | + self.assertEqual(len(results), 1) |
| 360 | + self.assertEqual(results[0].content, "Test content in post 2") |
| 361 | + |
353 | 362 | def test_related_method_filter(self): |
354 | 363 | """ |
355 | 364 | Missing MethodFilter filter methods are silently ignored, returning |
|
0 commit comments