-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add num_annotations to js-config group context
- Loading branch information
Showing
7 changed files
with
101 additions
and
1 deletion.
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
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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# pylint:disable=too-many-lines | ||
import datetime | ||
|
||
import elasticsearch_dsl | ||
|
@@ -345,6 +346,29 @@ def search(self, search, pyramid_request): | |
return search | ||
|
||
|
||
class TestSharedAnnotationsFilter: | ||
def test_it(self, pyramid_config, search, Annotation): | ||
userid = "acct:[email protected]" | ||
pyramid_config.testing_securitypolicy(userid) | ||
# Create two shared annotations, these should be counted. | ||
shared_annotations = [Annotation(shared=True), Annotation(shared=True)] | ||
# Create some "Only Me" annotations, these should not be counted even | ||
# if they belong to the authenticated user. | ||
Annotation(shared=False) | ||
Annotation(shared=False, userid=userid) | ||
|
||
result = search.run(webob.multidict.MultiDict({})) | ||
|
||
assert sorted(result.annotation_ids) == sorted( | ||
[annotation.id for annotation in shared_annotations] | ||
) | ||
|
||
@pytest.fixture | ||
def search(self, search): | ||
search.append_modifier(query.SharedAnnotationsFilter()) | ||
return search | ||
|
||
|
||
class TestGroupFilter: | ||
def test_matches_only_annotations_from_specified_groups( | ||
self, search, Annotation, groups, group_service, pyramid_request | ||
|
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