Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: tests/test_stats/test_filtehits_loader.py

Issue 30037555: NoIssue - Added filterhit statistics loading capability
Patch Set: Addressed Initial Comments Created April 3, 2019, 5:15 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/test_stats/data/filterhits_missing_columns.csv ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 @pytest.fixture
28 def filterhits_file_missing_columns():
29 return py.path.local(__file__).dirpath('data').join(
30 'filterhits_missing_columns.csv',
31 )
32
33
34 def test_filterhits_load_no_filtering(filterhits_file):
35 entries = load_filterhit_statistics(str(filterhits_file))
36
37 count = 0
38
39 for entry in entries:
40 count += 1
41 assert isinstance(entry['hits'], int)
42 assert isinstance(entry['onehour_sessions'], int)
43 assert isinstance(entry['domains'], int)
44 assert isinstance(entry['rootdomains'], int)
45
46 assert count == 2
47
48
49 @pytest.mark.parametrize('sources,exp_count', [
50 (['www.exceptionlist.com'], 1),
51 (['www.exceptionlist.com', 'www.blocklist.com'], 2),
52 (['inexistent_source', 'foo', 'bar'], 0),
53 ])
54 def test_filterhits_load_with_filtering(sources, exp_count, filterhits_file):
55 entries = load_filterhit_statistics(str(filterhits_file), sources)
56
57 count = 0
58 for _ in entries:
59 count += 1
60
61 assert count == exp_count
62
63
64 def test_filterhits_load_missing_columns(filterhits_file_missing_columns):
65 entries = load_filterhit_statistics(str(filterhits_file_missing_columns))
66
67 count = 0
68 for _ in entries:
69 count += 1
70
71 assert count == 2
OLDNEW
« no previous file with comments | « tests/test_stats/data/filterhits_missing_columns.csv ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld