Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: tests/test_parser.py

Issue 29873561: Issue 6920 - Only parse metadata from the top of the file (Closed)
Patch Set: Close metadata on everything but headers or comments Created Sept. 4, 2018, 8:22 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « abp/filters/parser.py ('k') | tests/test_rpy.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/test_parser.py
===================================================================
--- a/tests/test_parser.py
+++ b/tests/test_parser.py
@@ -21,7 +21,7 @@
parse_line, parse_filterlist, ParseError,
SELECTOR_TYPE as ST, FILTER_ACTION as FA, FILTER_OPTION as OPT,
)
-from abp.filters.parser import Comment, Metadata
+from abp.filters.parser import Comment, Metadata, Header
def test_parse_empty():
@@ -147,13 +147,6 @@
assert line.text == 'Block foo'
-def test_parse_meta():
- line = parse_line('! Homepage : http://aaa.com/b')
- assert line.type == 'metadata'
- assert line.key == 'Homepage'
- assert line.value == 'http://aaa.com/b'
-
-
def test_parse_instruction():
line = parse_line('%include foo:bar/baz.txt%')
assert line.type == 'include'
@@ -165,20 +158,26 @@
parse_line('%foo bar%')
-def test_parse_header():
- line = parse_line('[Adblock Plus 1.1]')
- assert line.type == 'header'
- assert line.version == 'Adblock Plus 1.1'
-
-
def test_parse_bad_header():
with pytest.raises(ParseError):
parse_line('[Adblock 1.1]')
def test_parse_filterlist():
- result = parse_filterlist(['! foo', '! Title: bar'])
- assert list(result) == [Comment('foo'), Metadata('Title', 'bar')]
+ result = parse_filterlist(['[Adblock Plus 1.1]',
rhowell 2018/09/05 02:50:06 It might be good to include the 'Last modified' co
Sebastian Noack 2018/09/05 09:09:51 Done.
+ '! Homepage : http://aaa.com/b',
+ '||example.com^',
+ '! Checksum: OaopkIiiAl77sSHk/VAWDA',
+ '! Note: bla bla'])
+
+ assert next(result) == Header('Adblock Plus 1.1')
+ assert next(result) == Metadata('Homepage', 'http://aaa.com/b')
+ assert next(result).type == 'filter'
+ assert next(result) == Metadata('Checksum', 'OaopkIiiAl77sSHk/VAWDA')
+ assert next(result).type == 'comment'
+
+ with pytest.raises(StopIteration):
+ next(result)
def test_exception_timing():
« no previous file with comments | « abp/filters/parser.py ('k') | tests/test_rpy.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld