| Left: | ||
| Right: |
| LEFT | RIGHT |
|---|---|
| 1 # This file is part of Adblock Plus <https://adblockplus.org/>, | 1 # This file is part of Adblock Plus <https://adblockplus.org/>, |
| 2 # Copyright (C) 2006-present eyeo GmbH | 2 # Copyright (C) 2006-present eyeo GmbH |
| 3 # | 3 # |
| 4 # Adblock Plus is free software: you can redistribute it and/or modify | 4 # Adblock Plus is free software: you can redistribute it and/or modify |
| 5 # it under the terms of the GNU General Public License version 3 as | 5 # it under the terms of the GNU General Public License version 3 as |
| 6 # published by the Free Software Foundation. | 6 # published by the Free Software Foundation. |
| 7 # | 7 # |
| 8 # Adblock Plus is distributed in the hope that it will be useful, | 8 # Adblock Plus is distributed in the hope that it will be useful, |
| 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 24 | 24 |
| 25 | 25 |
| 26 _SAMPLE_TUPLE = namedtuple('tuple', 'foo,bar') | 26 _SAMPLE_TUPLE = namedtuple('tuple', 'foo,bar') |
| 27 | 27 |
| 28 _TEST_EXAMPLES = { | 28 _TEST_EXAMPLES = { |
| 29 'header': { | 29 'header': { |
| 30 'in': b'[Adblock Plus 2.0]', | 30 'in': b'[Adblock Plus 2.0]', |
| 31 'out': { | 31 'out': { |
| 32 b'type': b'Header', | 32 b'type': b'Header', |
| 33 b'version': b'Adblock Plus 2.0', | 33 b'version': b'Adblock Plus 2.0', |
| 34 }, | |
| 35 }, | |
| 36 'metadata': { | |
| 37 'in': b'! Title: Example list', | |
| 38 'out': { | |
| 39 b'type': b'Metadata', | |
| 40 b'key': b'Title', | |
| 41 b'value': b'Example list', | |
| 34 }, | 42 }, |
| 35 }, | 43 }, |
| 36 'comment': { | 44 'comment': { |
| 37 'in': b'! Comment', | 45 'in': b'! Comment', |
| 38 'out': { | 46 'out': { |
| 39 b'type': b'Comment', | 47 b'type': b'Comment', |
| 40 b'text': b'Comment', | 48 b'text': b'Comment', |
| 41 }, | 49 }, |
| 42 }, | 50 }, |
| 43 'empty': { | 51 'empty': { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 data = line2dict(_TEST_EXAMPLES[line_type]['in']) | 136 data = line2dict(_TEST_EXAMPLES[line_type]['in']) |
| 129 check_data_utf8(data) | 137 check_data_utf8(data) |
| 130 | 138 |
| 131 | 139 |
| 132 @pytest.mark.parametrize('line_type', list(_TEST_EXAMPLES.keys())) | 140 @pytest.mark.parametrize('line_type', list(_TEST_EXAMPLES.keys())) |
| 133 def test_line2dict_format(line_type): | 141 def test_line2dict_format(line_type): |
| 134 """Test that the API result has the appropriate format. | 142 """Test that the API result has the appropriate format. |
| 135 | 143 |
| 136 Checks for both keys and datatypes. | 144 Checks for both keys and datatypes. |
| 137 """ | 145 """ |
| 138 mode = 'start' if line_type == 'header' else 'body' | 146 position = 'start' if line_type in {'header', 'metadata'} else 'body' |
| 139 data = line2dict(_TEST_EXAMPLES[line_type]['in'], mode) | 147 data = line2dict(_TEST_EXAMPLES[line_type]['in'], position) |
|
Sebastian Noack
2018/09/18 15:19:08
Note that I removed the test case for metadata her
Vasily Kuznetsov
2018/09/18 18:11:44
Done.
| |
| 140 | 148 |
| 141 assert data == _TEST_EXAMPLES[line_type]['out'] | 149 assert data == _TEST_EXAMPLES[line_type]['out'] |
| LEFT | RIGHT |