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

Unified Diff: tests/test_rpy.py

Issue 29988581: Issue 7230 - python-abp line2dict vectorization (Closed) Base URL: https://hg.adblockplus.org/python-abp/
Patch Set: Separate tests Created Jan. 29, 2019, 1:43 a.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/rpy.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/test_rpy.py
===================================================================
--- a/tests/test_rpy.py
+++ b/tests/test_rpy.py
@@ -20,7 +20,7 @@
import pytest
import sys
-from abp.filters.rpy import tuple2dict, line2dict
+from abp.filters.rpy import tuple2dict, line2dict, lines2dicts
_SAMPLE_TUPLE = namedtuple('tuple', 'foo,bar')
@@ -147,3 +147,28 @@
data = line2dict(_TEST_EXAMPLES[line_type]['in'], position)
assert data == _TEST_EXAMPLES[line_type]['out']
+
+
+def test_lines2dicts_start_mode():
+ """Test that the API returns the correct result in the appropriate format.
+
+ Checks for 'start' mode, which can handle headers and metadata.
+ """
+ tests = [t for t in _TEST_EXAMPLES.values()]
+ ins = [ex['in'] for ex in tests]
+ outs = [ex['out'] for ex in tests]
+
+ assert lines2dicts(ins, 'start') == outs
+
+
+def test_lines2dicts_default():
+ """Test that the API returns the correct result in the appropriate format.
+
+ By default, lines2dicts() does not correctly parse headers and metadata.
+ """
+ tests = [t for t in _TEST_EXAMPLES.values()
+ if t['out'][b'type'] not in {b'Header', b'Metadata'}]
+ ins = [ex['in'] for ex in tests]
+ outs = [ex['out'] for ex in tests]
+
+ assert lines2dicts(ins) == outs
« no previous file with comments | « abp/filters/rpy.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld