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: Removed db.testing flag, instead overwrite config during testing. Created March 30, 2015, 12:58 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/multiplexer.fcgi b/sitescripts/filterhits/test/test_helpers.py
old mode 100755
new mode 100644
similarity index 50%
copy from multiplexer.fcgi
copy to sitescripts/filterhits/test/test_helpers.py
index d72b2c18a6d7e04b211354ec3a3e38895f74ed65..5c89b39632d034cd13cb8b4945b0192199a288ad
--- a/multiplexer.fcgi
+++ b/sitescripts/filterhits/test/test_helpers.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
# coding: utf-8
# This file is part of the Adblock Plus web scripts,
@@ -16,17 +15,25 @@
# 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 os, re
-from flup.server.fcgi import WSGIServer
+import os
-from sitescripts.web import multiplex
+from sitescripts.utils import get_config
-bindAddress = None
-if 'FCGI_BIND_ADDRESS' in os.environ:
- match = re.match(r'^(.*?):(\d+)$', os.environ['FCGI_BIND_ADDRESS'])
- bindAddress = (match.group(1), int(match.group(2)))
-srv = WSGIServer(multiplex, debug=False, bindAddress=bindAddress)
+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": os.path.join(os.path.dirname(__file__), "temp")
+}
-if __name__ == '__main__':
- srv.run()
+def setup_config():
+ config.set("filterhitstats", "database", test_config["database"])
+ config.set("filterhitstats", "log_dir", test_config["log_dir"])
Wladimir Palant 2015/03/30 13:13:46 Maybe create a real temporary directory rather tha
kzar 2015/03/30 15:14:53 Done.
+ return config
+def restore_config():
+ config.set("filterhitstats", "database", live_config["database"])
+ config.set("filterhitstats", "log_dir", live_config["log_dir"])
Wladimir Palant 2015/03/30 13:13:46 Remove the temporary log directory here?
kzar 2015/03/30 15:14:53 Done.
« 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