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

Unified Diff: sitescripts/filterhits/test/test_helpers.py

Issue 4615801646612480: Issue 395 - Filter hits statistics backend (Closed)
Patch Set: Make test log directory path configurable and ensure it's always cleared. Created March 30, 2015, 3:12 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
« no previous file with comments | « sitescripts/filterhits/test/log_tests.py ('k') | sitescripts/filterhits/web/__init__.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sitescripts/filterhits/test/test_helpers.py
diff --git a/sitescripts/filterhits/test/test_helpers.py b/sitescripts/filterhits/test/test_helpers.py
new file mode 100644
index 0000000000000000000000000000000000000000..24e11134c134622a87e9a44695afa47abdbc3e73
--- /dev/null
+++ b/sitescripts/filterhits/test/test_helpers.py
@@ -0,0 +1,40 @@
+# coding: utf-8
+
+# This file is part of the Adblock Plus web scripts,
+# Copyright (C) 2006-2015 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 shutil
+
+from sitescripts.utils import get_config
+
+config = get_config()
+live_config = {
+ "database": config.get("filterhitstats", "database"),
+ "log_dir": config.get("filterhitstats", "log_dir")
+}
+test_config = {
+ "database": config.get("filterhitstats", "test_database"),
+ "log_dir": config.get("filterhitstats", "test_log_dir")
Wladimir Palant 2015/03/30 18:35:53 Why configure that directory? setup_config() can c
kzar 2015/03/30 19:01:35 Done.
+}
+
+def setup_config():
+ config.set("filterhitstats", "database", test_config["database"])
+ config.set("filterhitstats", "log_dir", test_config["log_dir"])
+ return config
+
+def restore_config():
+ config.set("filterhitstats", "database", live_config["database"])
+ config.set("filterhitstats", "log_dir", live_config["log_dir"])
+ shutil.rmtree(test_config["log_dir"], ignore_errors=True)
« no previous file with comments | « sitescripts/filterhits/test/log_tests.py ('k') | sitescripts/filterhits/web/__init__.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld