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: Created Jan. 24, 2019, 3:37 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
« abp/filters/rpy.py ('K') | « 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, lines2dict
_SAMPLE_TUPLE = namedtuple('tuple', 'foo,bar')
@@ -147,3 +147,25 @@
data = line2dict(_TEST_EXAMPLES[line_type]['in'], position)
assert data == _TEST_EXAMPLES[line_type]['out']
+
+
+def test_lines2dict():
+ """Test that the API result has the appropriate format.
+
+ Checks for both keys and datatypes.
+ """
+ string_list = []
+ line_types = {b'EmptyLine': 'empty', b'Filter': 'filter_single',
+ b'Comment': 'comment', b'Include': 'include',
+ b'Header': 'header', b'Metadata': 'metadata'}
+
+ for key in _TEST_EXAMPLES.keys():
+ string_list.append(_TEST_EXAMPLES[key]['in'])
+
+ result_dict = lines2dict(string_list)
+
+ for line in result_dict.keys():
+ line_type = line_types[result_dict[line][b'type']]
+ data = line2dict(_TEST_EXAMPLES[line_type]['in'], 'start')
+
+ assert data == _TEST_EXAMPLES[line_type]['out']
« abp/filters/rpy.py ('K') | « abp/filters/rpy.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld