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

Unified Diff: tests/test_stats/test_filtehits_loader.py

Issue 30037555: NoIssue - Added filterhit statistics loading capability
Patch Set: Removed .DS_Store files Created April 3, 2019, 4:16 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/test_stats/test_filtehits_loader.py
diff --git a/tests/test_stats/test_filtehits_loader.py b/tests/test_stats/test_filtehits_loader.py
new file mode 100644
index 0000000000000000000000000000000000000000..4a490537f97af09e02d7355c7c552af1a90d4797
--- /dev/null
+++ b/tests/test_stats/test_filtehits_loader.py
@@ -0,0 +1,53 @@
+# 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/>.
+
+import pytest
+import py
+
+from abp.stats.filterhits import load_filterhit_statistics
+
+
+@pytest.fixture
+def filterhits_file():
+ return py.path.local(__file__).dirpath('data').join('filterhits.csv')
+
+
+def test_filterhits_load_no_filtering(filterhits_file):
+ entries = load_filterhit_statistics(str(filterhits_file))
+
+ count = 0
+
+ for entry in entries:
+ count += 1
+ assert isinstance(entry['hits'], int)
+ assert isinstance(entry['onehour_sessions'], int)
+
+ assert count == 9
+
+
+@pytest.mark.parametrize('sources,exp_count', [
+ (['https://easylist-downloads.adblockplus.org/easylist.txt'], 4),
+ (['https://easylist-downloads.adblockplus.org/exceptionrules.txt'], 4),
+ (['inexistent_source', 'foo', 'bar'], 0),
+])
+def test_filterhits_load_with_filtering(sources, exp_count, filterhits_file):
+ entries = load_filterhit_statistics(str(filterhits_file), sources)
+
+ count = 0
+
+ for entry in entries:
+ count += 1
+
+ assert count == exp_count
« tests/test_stats/data/filterhits.csv ('K') | « tests/test_stats/data/filterhits.csv ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld