OLD | NEW |
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 b'target': b'www.test.py/filtelist.txt', | 61 b'target': b'www.test.py/filtelist.txt', |
62 }, | 62 }, |
63 }, | 63 }, |
64 'filter_single': { | 64 'filter_single': { |
65 'in': b'foo.com##div#ad1', | 65 'in': b'foo.com##div#ad1', |
66 'out': { | 66 'out': { |
67 b'type': b'Filter', | 67 b'type': b'Filter', |
68 b'text': b'foo.com##div#ad1', | 68 b'text': b'foo.com##div#ad1', |
69 b'selector': {b'type': b'css', b'value': b'div#ad1'}, | 69 b'selector': {b'type': b'css', b'value': b'div#ad1'}, |
70 b'action': b'hide', | 70 b'action': b'hide', |
71 b'options': [(b'domain', [(b'foo.com', True)])], | 71 b'options': {b'domain': {b'foo.com': True}}, |
72 }, | 72 }, |
73 }, | 73 }, |
74 'filter_with_%': { | 74 'filter_with_%': { |
75 'in': b'%22banner%*%22idzone%', | 75 'in': b'%22banner%*%22idzone%', |
76 'out': { | 76 'out': { |
77 b'type': b'Filter', | 77 b'type': b'Filter', |
78 b'text': b'%22banner%*%22idzone%', | 78 b'text': b'%22banner%*%22idzone%', |
79 b'selector': {b'type': b'url-pattern', | 79 b'selector': {b'type': b'url-pattern', |
80 b'value': b'%22banner%*%22idzone%'}, | 80 b'value': b'%22banner%*%22idzone%'}, |
81 b'action': b'block', | 81 b'action': b'block', |
82 b'options': [], | 82 b'options': {}, |
83 }, | 83 }, |
84 }, | 84 }, |
85 'filter_multiple': { | 85 'filter_multiple': { |
86 'in': b'foo.com,bar.com##div#ad1', | 86 'in': b'foo.com,bar.com##div#ad1', |
87 'out': { | 87 'out': { |
88 b'type': b'Filter', | 88 b'type': b'Filter', |
89 b'text': b'foo.com,bar.com##div#ad1', | 89 b'text': b'foo.com,bar.com##div#ad1', |
90 b'selector': {b'type': b'css', b'value': b'div#ad1'}, | 90 b'selector': {b'type': b'css', b'value': b'div#ad1'}, |
91 b'action': b'hide', | 91 b'action': b'hide', |
92 b'options': [(b'domain', [(b'foo.com', True), (b'bar.com', | 92 b'options': {b'domain': {b'foo.com': True, b'bar.com': True}}, |
93 True)])], | |
94 }, | 93 }, |
95 }, | 94 }, |
96 } | 95 } |
97 | 96 |
98 | 97 |
99 def check_data_utf8(data): | 98 def check_data_utf8(data): |
100 """Check if all the strings in a dict are encoded as unicode. | 99 """Check if all the strings in a dict are encoded as unicode. |
101 | 100 |
102 Parameters | 101 Parameters |
103 ---------- | 102 ---------- |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 """Test that the API returns the correct result in the appropriate format. | 175 """Test that the API returns the correct result in the appropriate format. |
177 | 176 |
178 By default, lines2dicts() does not correctly parse headers and metadata. | 177 By default, lines2dicts() does not correctly parse headers and metadata. |
179 """ | 178 """ |
180 tests = [t for t in _TEST_EXAMPLES.values() | 179 tests = [t for t in _TEST_EXAMPLES.values() |
181 if t['out'][b'type'] not in {b'Header', b'Metadata'}] | 180 if t['out'][b'type'] not in {b'Header', b'Metadata'}] |
182 ins = [ex['in'] for ex in tests] | 181 ins = [ex['in'] for ex in tests] |
183 outs = [ex['out'] for ex in tests] | 182 outs = [ex['out'] for ex in tests] |
184 | 183 |
185 assert lines2dicts(ins) == outs | 184 assert lines2dicts(ins) == outs |
OLD | NEW |