-
Notifications
You must be signed in to change notification settings - Fork 422
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5413 from hypothesis/remove-unused-stream-filter-…
…features Remove unused and untested code from h/streamer/filter.py
- Loading branch information
Showing
3 changed files
with
104 additions
and
147 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,65 @@ | ||
from __future__ import unicode_literals | ||
|
||
from h.streamer.filter import FilterHandler | ||
|
||
|
||
class TestFilterHandler(object): | ||
def test_it_matches_uri(self): | ||
query = { | ||
"match_policy": "include_any", | ||
"actions": {}, | ||
"clauses": [ | ||
{ | ||
"field": "/uri", | ||
"operator": "one_of", | ||
"value": ["https://example.com", "https://example.org"], | ||
} | ||
], | ||
} | ||
handler = FilterHandler(query) | ||
|
||
ann = {"id": "123", "uri": "https://example.com"} | ||
assert handler.match(ann) is True | ||
|
||
ann = {"id": "123", "uri": "https://example.net"} | ||
assert handler.match(ann) is False | ||
|
||
def test_it_matches_id(self): | ||
query = { | ||
"match_policy": "include_any", | ||
"actions": {}, | ||
"clauses": [ | ||
{ | ||
"field": "/id", | ||
"operator": "equals", | ||
"value": "123", | ||
} | ||
], | ||
} | ||
handler = FilterHandler(query) | ||
|
||
ann = {"id": "123", "uri": "https://example.com"} | ||
assert handler.match(ann) is True | ||
|
||
ann = {"id": "456", "uri": "https://example.net"} | ||
assert handler.match(ann) is False | ||
|
||
def test_it_matches_parent_id(self): | ||
query = { | ||
"match_policy": "include_any", | ||
"actions": {}, | ||
"clauses": [ | ||
{ | ||
"field": "/references", | ||
"operator": "one_of", | ||
"value": "123", | ||
} | ||
], | ||
} | ||
handler = FilterHandler(query) | ||
|
||
ann = {"id": "abc", "uri": "https://example.com", "references": ["123"]} | ||
assert handler.match(ann) is True | ||
|
||
ann = {"id": "abc", "uri": "https://example.com", "references": ["456"]} | ||
assert handler.match(ann) is False |
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