Index: tests/test_parser.py |
=================================================================== |
--- a/tests/test_parser.py |
+++ b/tests/test_parser.py |
@@ -19,7 +19,7 @@ |
from abp.filters import ( |
parse_line, parse_filterlist, ParseError, |
- SELECTOR_TYPE as ST, FILTER_ACTION as FA, FILTER_OPTION as OPT, |
+ SelectorType as St, FilterAction as Fa, FilterOption as Opt, |
rhowell
2019/01/12 01:25:31
I wasn't sure what best practices were for this na
Vasily Kuznetsov
2019/01/12 19:23:38
Yeah, I agree about the oddness. Maybe just the fi
rhowell
2019/01/12 21:18:34
That produces another flake8 error: `N814 camelcas
Vasily Kuznetsov
2019/01/14 14:14:35
I see. Pep8-naming is stricter than I expected. Th
|
) |
from abp.filters.parser import Comment, Metadata, Header |
@@ -32,47 +32,47 @@ |
@pytest.mark.parametrize('filter_text, expected', { |
# Blocking filters with patterns and regexps and blocking exceptions. |
'*asdf*d**dd*': { |
- 'selector': {'type': ST.URL_PATTERN, 'value': '*asdf*d**dd*'}, |
- 'action': FA.BLOCK, |
+ 'selector': {'type': St.URL_PATTERN, 'value': '*asdf*d**dd*'}, |
+ 'action': Fa.BLOCK, |
}, |
'@@|*asd|f*d**dd*|': { |
- 'selector': {'type': ST.URL_PATTERN, 'value': '|*asd|f*d**dd*|'}, |
- 'action': FA.ALLOW, |
+ 'selector': {'type': St.URL_PATTERN, 'value': '|*asd|f*d**dd*|'}, |
+ 'action': Fa.ALLOW, |
}, |
'/ddd|f?a[s]d/': { |
- 'selector': {'type': ST.URL_REGEXP, 'value': 'ddd|f?a[s]d'}, |
- 'action': FA.BLOCK, |
+ 'selector': {'type': St.URL_REGEXP, 'value': 'ddd|f?a[s]d'}, |
+ 'action': Fa.BLOCK, |
}, |
'@@/ddd|f?a[s]d/': { |
- 'selector': {'type': ST.URL_REGEXP, 'value': 'ddd|f?a[s]d'}, |
- 'action': FA.ALLOW, |
+ 'selector': {'type': St.URL_REGEXP, 'value': 'ddd|f?a[s]d'}, |
+ 'action': Fa.ALLOW, |
}, |
# Blocking filters with some options. |
'bla$match-case,~script,domain=foo.com|~bar.com,sitekey=foo': { |
- 'selector': {'type': ST.URL_PATTERN, 'value': 'bla'}, |
- 'action': FA.BLOCK, |
+ 'selector': {'type': St.URL_PATTERN, 'value': 'bla'}, |
+ 'action': Fa.BLOCK, |
'options': [ |
- (OPT.MATCH_CASE, True), |
- (OPT.SCRIPT, False), |
- (OPT.DOMAIN, [('foo.com', True), ('bar.com', False)]), |
- (OPT.SITEKEY, ['foo']), |
+ (Opt.MATCH_CASE, True), |
+ (Opt.SCRIPT, False), |
+ (Opt.DOMAIN, [('foo.com', True), ('bar.com', False)]), |
+ (Opt.SITEKEY, ['foo']), |
], |
}, |
'@@http://bla$~script,~other,sitekey=foo|bar': { |
- 'selector': {'type': ST.URL_PATTERN, 'value': 'http://bla'}, |
- 'action': FA.ALLOW, |
+ 'selector': {'type': St.URL_PATTERN, 'value': 'http://bla'}, |
+ 'action': Fa.ALLOW, |
'options': [ |
- (OPT.SCRIPT, False), |
- (OPT.OTHER, False), |
- (OPT.SITEKEY, ['foo', 'bar']), |
+ (Opt.SCRIPT, False), |
+ (Opt.OTHER, False), |
+ (Opt.SITEKEY, ['foo', 'bar']), |
], |
}, |
"||foo.com^$csp=script-src 'self' * 'unsafe-inline',script,sitekey=foo," |
+ 'other,match-case,domain=foo.com': { |
- 'selector': {'type': ST.URL_PATTERN, 'value': '||foo.com^'}, |
- 'action': FA.BLOCK, |
+ 'selector': {'type': St.URL_PATTERN, 'value': '||foo.com^'}, |
+ 'action': Fa.BLOCK, |
'options': [ |
- (OPT.CSP, "script-src 'self' * 'unsafe-inline'"), |
+ (Opt.CSP, "script-src 'self' * 'unsafe-inline'"), |
('script', True), |
('sitekey', ['foo']), |
('other', True), |
@@ -81,8 +81,8 @@ |
], |
}, |
'@@bla$script,other,domain=foo.com|~bar.foo.com,csp=c s p': { |
- 'selector': {'type': ST.URL_PATTERN, 'value': 'bla'}, |
- 'action': FA.ALLOW, |
+ 'selector': {'type': St.URL_PATTERN, 'value': 'bla'}, |
+ 'action': Fa.ALLOW, |
'options': [ |
('script', True), |
('other', True), |
@@ -91,42 +91,42 @@ |
], |
}, |
'||content.server.com/files/*.php$rewrite=$1': { |
- 'selector': {'type': ST.URL_PATTERN, |
+ 'selector': {'type': St.URL_PATTERN, |
'value': '||content.server.com/files/*.php'}, |
- 'action': FA.BLOCK, |
+ 'action': Fa.BLOCK, |
'options': [ |
('rewrite', '$1'), |
], |
}, |
# Element hiding filters and exceptions. |
'##ddd': { |
- 'selector': {'type': ST.CSS, 'value': 'ddd'}, |
- 'action': FA.HIDE, |
+ 'selector': {'type': St.CSS, 'value': 'ddd'}, |
+ 'action': Fa.HIDE, |
'options': [], |
}, |
'#@#body > div:first-child': { |
- 'selector': {'type': ST.CSS, 'value': 'body > div:first-child'}, |
- 'action': FA.SHOW, |
+ 'selector': {'type': St.CSS, 'value': 'body > div:first-child'}, |
+ 'action': Fa.SHOW, |
'options': [], |
}, |
'foo,~bar##ddd': { |
- 'options': [(OPT.DOMAIN, [('foo', True), ('bar', False)])], |
+ 'options': [(Opt.DOMAIN, [('foo', True), ('bar', False)])], |
}, |
# Element hiding emulation filters (extended CSS). |
'foo,~bar#?#:-abp-properties(abc)': { |
- 'selector': {'type': ST.XCSS, 'value': ':-abp-properties(abc)'}, |
- 'action': FA.HIDE, |
- 'options': [(OPT.DOMAIN, [('foo', True), ('bar', False)])], |
+ 'selector': {'type': St.XCSS, 'value': ':-abp-properties(abc)'}, |
+ 'action': Fa.HIDE, |
+ 'options': [(Opt.DOMAIN, [('foo', True), ('bar', False)])], |
}, |
'foo.com#?#aaa :-abp-properties(abc) bbb': { |
'selector': { |
- 'type': ST.XCSS, |
+ 'type': St.XCSS, |
'value': 'aaa :-abp-properties(abc) bbb', |
}, |
}, |
'#?#:-abp-properties(|background-image: url(data:*))': { |
'selector': { |
- 'type': ST.XCSS, |
+ 'type': St.XCSS, |
'value': ':-abp-properties(|background-image: url(data:*))', |
}, |
'options': [], |