Index: tests/test_differ.py |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/tests/test_differ.py |
@@ -0,0 +1,77 @@ |
+# This file is part of Adblock Plus <https://adblockplus.org/>, |
+# Copyright (C) 2006-present eyeo GmbH |
+# |
+# Adblock Plus is free software: you can redistribute it and/or modify |
+# it under the terms of the GNU General Public License version 3 as |
+# published by the Free Software Foundation. |
+# |
+# Adblock Plus is distributed in the hope that it will be useful, |
+# but WITHOUT ANY WARRANTY; without even the implied warranty of |
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
+# GNU General Public License for more details. |
+# |
+# You should have received a copy of the GNU General Public License |
+# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
+ |
+ |
+from abp.filters.renderer import render_diff |
+ |
+BASE = '''[Adblock Plus 2.0] |
+! Checksum: O6rd2aavziYFTXVIGAMimg |
+! Version: 111 |
+! Diff-URL: https://easylist-downloads.adblockplus.org/easylist/diffs/111.txt |
+! Diff-Expires: 1 hours |
+! Title: EasyList |
+! Last modified: 26 Jul 2018 02:10 UTC |
+! Expires: 1 days (update frequency) |
+! Homepage: https://easylist.to/ |
+! Licence: https://easylist.to/pages/licence.html |
+! |
+! Please report any unblocked adverts or problems |
+! in the forums (https://forums.lanik.us/) |
+! or via e-mail (easylist.subscription@gmail.com). |
+! |
+!-----------------------General advert blocking filters-----------------------! |
+! *** easylist:easylist/easylist_general_block.txt *** |
+test |
+&act=ads_ |
+&ad.vid=$~xmlhttprequest |
+&ad_box_ |
+''' |
+ |
+LATEST = '''[Adblock Plus 2.0] |
+! Checksum: H6T/6rjr+cjtpbghFTBTng |
+! Version: 123 |
+! Diff-URL: https://easylist-downloads.adblockplus.org/easylist/diffs/123.txt |
+! Diff-Expires: 1 hours |
+! Title: EasyList |
+! Last modified: 26 Jul 2018 21:00 UTC |
+! Homepage: https://easylist.to/ |
+! Licence: https://easylist.to/pages/licence.html |
+! |
+! Please report any unblocked adverts or problems |
+! in the forums (https://forums.lanik.us/) |
+! or via e-mail (easylist.subscription@gmail.com). |
+! |
+!-----------------------General advert blocking filters-----------------------! |
+! *** easylist:easylist/easylist_general_block.txt *** |
+&act=ads_ |
+&ad_box_ |
+&ad_channel= |
+test |
Sebastian Noack
2018/08/21 19:42:46
Perhaps add a leading whitespace here, so that we
rhowell
2018/08/27 22:06:27
Done.
|
+''' |
+ |
+ |
+EXPECTED = '''[Adblock Plus Diff] |
+! Diff-URL: https://easylist-downloads.adblockplus.org/easylist/diffs/123.txt |
+! Expires: |
+! Version: 123 |
++ &ad_channel= |
+- &ad.vid=$~xmlhttprequest |
+''' |
+ |
+ |
+def test_differ(): |
+ exp = set(EXPECTED.splitlines()) |
+ gen = set(render_diff(BASE.splitlines(), LATEST.splitlines())) |
+ assert(gen == exp) |