LEFT | RIGHT |
1 # This file is part of the Adblock Plus web scripts, | 1 # This file is part of the Adblock Plus web scripts, |
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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 raise urllib2.URLError('Ugly') | 67 raise urllib2.URLError('Ugly') |
68 return real_urlopen(url) | 68 return real_urlopen(url) |
69 | 69 |
70 mocker.patch('urllib2.urlopen', mock_urlopen) | 70 mocker.patch('urllib2.urlopen', mock_urlopen) |
71 | 71 |
72 | 72 |
73 def test_good(md_repo): | 73 def test_good(md_repo): |
74 main() | 74 main() |
75 subprocess.check_call(['hg', 'up'], cwd=md_repo.strpath) | 75 subprocess.check_call(['hg', 'up'], cwd=md_repo.strpath) |
76 result = md_repo.join('malwaredomains_full.txt').read() | 76 result = md_repo.join('malwaredomains_full.txt').read() |
77 puny_urls = ['.cn-w48dx81cufdl6b', '.tw-u68dw51cgbz81a'] | 77 puny_urls = ['xn--xhq02ykwbp4a.cn', 'xn--fiq80yua78t.tw'] |
78 for url in puny_urls: | 78 for url in puny_urls: |
79 assert url in result | 79 assert url in result |
80 | 80 |
81 | 81 |
82 def test_bad(md_repo, config): | 82 def test_bad(md_repo, config): |
83 config.set(CONF_SECTION, 'malwaredomains_mirrors', 'bad') | 83 config.set(CONF_SECTION, 'malwaredomains_mirrors', 'bad') |
84 try: | 84 try: |
85 main() | 85 main() |
86 except SystemExit as exc: | 86 except SystemExit as exc: |
87 err_lines = str(exc).splitlines() | 87 err_lines = str(exc).splitlines() |
88 assert len(err_lines) == 3 | 88 assert len(err_lines) == 3 |
89 assert 'Failed to fetch bad/files/justdomains.zip' in err_lines[2] | 89 assert 'Failed to fetch bad/files/justdomains.zip' in err_lines[2] |
90 assert '42: No good' in err_lines[2] | 90 assert '42: No good' in err_lines[2] |
91 | 91 |
92 | 92 |
93 def test_ugly(md_repo, config): | 93 def test_ugly(md_repo, config): |
94 config.set(CONF_SECTION, 'malwaredomains_mirrors', 'bad\nugly') | 94 config.set(CONF_SECTION, 'malwaredomains_mirrors', 'bad\nugly') |
95 try: | 95 try: |
96 main() | 96 main() |
97 except SystemExit as exc: | 97 except SystemExit as exc: |
98 err_lines = str(exc).splitlines() | 98 err_lines = str(exc).splitlines() |
99 assert len(err_lines) == 4 | 99 assert len(err_lines) == 4 |
100 assert 'Failed to fetch bad/files/justdomains.zip' in err_lines[2] | 100 assert 'Failed to fetch bad/files/justdomains.zip' in err_lines[2] |
101 assert 'Failed to fetch ugly/files/justdomains.zip' in err_lines[3] | 101 assert 'Failed to fetch ugly/files/justdomains.zip' in err_lines[3] |
102 assert 'Ugly' in err_lines[3] | 102 assert 'Ugly' in err_lines[3] |
LEFT | RIGHT |