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 |
11 # GNU General Public License for more details. | 11 # GNU General Public License for more details. |
12 # | 12 # |
13 # You should have received a copy of the GNU General Public License | 13 # You should have received a copy of the GNU General Public License |
14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. | 14 # along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
15 | 15 |
16 | 16 |
17 from abp.create_diff import generate_diff | 17 from abp.filters.renderer import render_diff |
18 | |
19 | 18 |
20 BASE = '''[Adblock Plus 2.0] | 19 BASE = '''[Adblock Plus 2.0] |
21 ! Checksum: O6rd2aavziYFTXVIGAMimg | |
22 ! Version: 111 | 20 ! Version: 111 |
23 ! Diff-URL: https://easylist-downloads.adblockplus.org/easylist/diffs/111.txt | 21 ! diff-url: https://easylist-downloads.adblockplus.org/easylist/diffs/111.txt |
24 ! Diff-Expires: 1 hours | 22 ! diff-expires: 1 hours |
25 ! Title: EasyList | 23 ! Title: EasyList |
26 ! Last modified: 26 Jul 2018 02:10 UTC | 24 ! Last modified: 26 Jul 2018 02:10 UTC |
27 ! Expires: 1 days (update frequency) | 25 ! Expires: 1 days (update frequency) |
28 ! Homepage: https://easylist.to/ | 26 ! Homepage: https://easylist.to/ |
29 ! Licence: https://easylist.to/pages/licence.html | 27 ! Licence: https://easylist.to/pages/licence.html |
30 ! | 28 ! |
31 ! Please report any unblocked adverts or problems | 29 ! Please report any unblocked adverts or problems |
32 ! in the forums (https://forums.lanik.us/) | 30 ! in the forums (https://forums.lanik.us/) |
33 ! or via e-mail (easylist.subscription@gmail.com). | 31 ! or via e-mail (easylist.subscription@gmail.com). |
34 ! | 32 ! |
35 !-----------------------General advert blocking filters-----------------------! | 33 !-----------------------General advert blocking filters-----------------------! |
36 ! *** easylist:easylist/easylist_general_block.txt *** | 34 ! *** easylist:easylist/easylist_general_block.txt *** |
| 35 test |
37 &act=ads_ | 36 &act=ads_ |
38 &ad.vid=$~xmlhttprequest | 37 &ad.vid=$~xmlhttprequest |
39 &ad_box_ | 38 &ad_box_ |
40 ''' | 39 ''' |
41 | 40 |
42 LATEST = '''[Adblock Plus 2.0] | 41 LATEST = '''[Adblock Plus 2.0] |
43 ! Checksum: H6T/6rjr+cjtpbghFTBTng | |
44 ! Version: 123 | 42 ! Version: 123 |
45 ! Diff-URL: https://easylist-downloads.adblockplus.org/easylist/diffs/123.txt | 43 ! Diff-URL: https://easylist-downloads.adblockplus.org/easylist/diffs/123.txt |
46 ! Diff-Expires: 1 hours | 44 ! Diff-Expires: 1 hours |
47 ! Title: EasyList | 45 ! Title: EasyList |
48 ! Last modified: 26 Jul 2018 21:00 UTC | 46 ! Last modified: 26 Jul 2018 21:00 UTC |
49 ! Expires: 1 days (update frequency) | |
50 ! Homepage: https://easylist.to/ | 47 ! Homepage: https://easylist.to/ |
51 ! Licence: https://easylist.to/pages/licence.html | 48 ! Licence: https://easylist.to/pages/licence.html |
52 ! | 49 ! |
53 ! Please report any unblocked adverts or problems | 50 ! Please report any unblocked adverts or problems |
54 ! in the forums (https://forums.lanik.us/) | 51 ! in the forums (https://forums.lanik.us/) |
55 ! or via e-mail (easylist.subscription@gmail.com). | 52 ! or via e-mail (easylist.subscription@gmail.com). |
56 ! | 53 ! |
57 !-----------------------General advert blocking filters-----------------------! | 54 !-----------------------General advert blocking filters-----------------------! |
58 ! *** easylist:easylist/easylist_general_block.txt *** | 55 ! *** easylist:easylist/easylist_general_block.txt *** |
59 &act=ads_ | 56 &act=ads_ |
60 &ad_box_ | 57 &ad_box_ |
61 &ad_channel= | 58 &ad_channel= |
| 59 test |
62 ''' | 60 ''' |
63 | 61 |
64 | 62 |
65 EXPECTED = '''[Adblock Plus Diff 2.0] | 63 EXPECTED = '''[Adblock Plus Diff] |
66 ! Checksum: 1B2M2Y8AsgTpgAmY7PhCfg | 64 ! Diff-URL: https://easylist-downloads.adblockplus.org/easylist/diffs/123.txt |
| 65 ! Expires: |
67 ! Version: 123 | 66 ! Version: 123 |
68 ! Diff-URL: https://easylist-downloads.adblockplus.org/easylist/diffs/123.txt | |
69 ! Diff-Expires: 1 hours | |
70 ! Title: EasyList | |
71 ! Last modified: 26 Jul 2018 21:00 UTC | |
72 ! Expires: 1 days (update frequency) | |
73 ! Homepage: https://easylist.to/ | |
74 ! Licence: https://easylist.to/pages/licence.html | |
75 - &ad.vid=$~xmlhttprequest | 67 - &ad.vid=$~xmlhttprequest |
76 + &ad_channel= | 68 + &ad_channel= |
77 ''' | 69 ''' |
78 | 70 |
79 | 71 |
80 def test_differ(): | 72 def test_differ(): |
81 assert(generate_diff(BASE, LATEST) == EXPECTED) | 73 exp = set(EXPECTED.splitlines()) |
| 74 gen = set(render_diff(BASE.splitlines(), LATEST.splitlines())) |
| 75 assert(gen == exp) |
LEFT | RIGHT |