| 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) |