| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 # This file is part of Adblock Plus <https://adblockplus.org/>, | 
|  | 2 # Copyright (C) 2006-present eyeo GmbH | 
|  | 3 # | 
|  | 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 | 
|  | 6 # published by the Free Software Foundation. | 
|  | 7 # | 
|  | 8 # Adblock Plus is distributed in the hope that it will be useful, | 
|  | 9 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 
|  | 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
|  | 11 # GNU General Public License for more details. | 
|  | 12 # | 
|  | 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/>. | 
|  | 15 | 
|  | 16 import pytest | 
|  | 17 import py | 
|  | 18 | 
|  | 19 from abp.stats.filterhits import load_filterhit_statistics | 
|  | 20 | 
|  | 21 | 
|  | 22 @pytest.fixture | 
|  | 23 def filterhits_file(): | 
|  | 24     return py.path.local(__file__).dirpath('data').join('filterhits.csv') | 
|  | 25 | 
|  | 26 | 
|  | 27 def test_filterhits_load_no_filtering(filterhits_file): | 
|  | 28     entries = load_filterhit_statistics(str(filterhits_file)) | 
|  | 29 | 
|  | 30     count = 0 | 
|  | 31 | 
|  | 32     for entry in entries: | 
|  | 33         count += 1 | 
|  | 34         assert isinstance(entry['hits'], int) | 
|  | 35         assert isinstance(entry['onehour_sessions'], int) | 
|  | 36 | 
|  | 37     assert count == 9 | 
|  | 38 | 
|  | 39 | 
|  | 40 @pytest.mark.parametrize('sources,exp_count', [ | 
|  | 41     (['https://easylist-downloads.adblockplus.org/easylist.txt'], 4), | 
|  | 42     (['https://easylist-downloads.adblockplus.org/exceptionrules.txt'], 4), | 
|  | 43     (['inexistent_source', 'foo', 'bar'], 0), | 
|  | 44 ]) | 
|  | 45 def test_filterhits_load_with_filtering(sources, exp_count, filterhits_file): | 
|  | 46     entries = load_filterhit_statistics(str(filterhits_file), sources) | 
|  | 47 | 
|  | 48     count = 0 | 
|  | 49 | 
|  | 50     for entry in entries: | 
|  | 51         count += 1 | 
|  | 52 | 
|  | 53     assert count == exp_count | 
| OLD | NEW | 
|---|