-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EREGCSC-2549 Enable populated filter on admin panel (#1194)
* Remove filter by subpart, title etc Add filter by index populated Move filters to common directory "common/filters.py" * Add tests
- Loading branch information
Showing
4 changed files
with
46 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import pytest | ||
|
||
from common.filters import IndexPopulatedFilter | ||
from content_search.models import ContentIndex | ||
from file_manager.models import UploadedFile | ||
|
||
|
||
@pytest.mark.django_db | ||
def test_index_populated_filter(): | ||
a = UploadedFile.objects.create(document_name="a") | ||
b = UploadedFile.objects.create(document_name="b") | ||
ContentIndex.objects.create(file=a, content="Hello world") | ||
ContentIndex.objects.create(file=b) | ||
|
||
# Test when populated filter is not set | ||
results = IndexPopulatedFilter(None, {}, None, None).queryset(None, UploadedFile.objects.all()) | ||
assert a in results | ||
assert b in results | ||
|
||
# Test when populated filter is set to "yes" | ||
results = IndexPopulatedFilter(None, {"populated": "yes"}, None, None).queryset(None, UploadedFile.objects.all()) | ||
assert a in results | ||
assert b not in results | ||
|
||
# Test when populated filter is set to "no" | ||
results = IndexPopulatedFilter(None, {"populated": "no"}, None, None).queryset(None, UploadedFile.objects.all()) | ||
assert a not in results | ||
assert b in results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters