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..bf1c485692ce20b5ae0b2fc1bbcb11f9773b16f6 |
--- /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 tempfile |
+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") |
Sebastian Noack
2015/03/31 07:55:21
Maybe we should also have test_dbuser and test_dbp
kzar
2015/03/31 09:48:56
Done.
|
+} |
+ |
+def setup_config(): |
+ config.set("filterhitstats", "database", test_config["database"]) |
+ config.set("filterhitstats", "log_dir", tempfile.mkdtemp()) |
+ return config |
+ |
+def restore_config(): |
+ shutil.rmtree(config.get("filterhitstats", "log_dir"), ignore_errors=True) |
+ config.set("filterhitstats", "database", live_config["database"]) |
+ config.set("filterhitstats", "log_dir", live_config["log_dir"]) |