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'] |