changeset 4196:42660b499488

Replace conftest-Request with new WSGI-based request
author Florian Krupicka <florian.krupicka@googlemail.com>
date Sat, 28 Jun 2008 17:20:18 +0200
parents 2d8a9f98382b
children 4acb272b1759
files MoinMoin/conftest.py MoinMoin/web/request.py
diffstat 2 files changed, 17 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/conftest.py	Sat Jun 28 15:36:50 2008 +0200
+++ b/MoinMoin/conftest.py	Sat Jun 28 17:20:18 2008 +0200
@@ -71,20 +71,15 @@
 
 
 def init_test_request(static_state=[False]):
-    from MoinMoin.request import request_cli
-    from MoinMoin.user import User
-    from MoinMoin.formatter.text_html import Formatter as HtmlFormatter
+    from MoinMoin.web.request import create_request
+    from MoinMoin.wsgiapp import init as request_init
     if not static_state[0]:
         maketestwiki.run(True)
         static_state[0] = True
-    request = request_cli.Request()
-    request.form = request.args = request.setup_args()
-    request.user = User(request)
-    request.html_formatter = HtmlFormatter(request)
-    request.formatter = request.html_formatter
+    request = create_request()
+    request = request_init(request)
     return request
 
-
 class TestConfig:
     """ Custom configuration for unit tests
 
--- a/MoinMoin/web/request.py	Sat Jun 28 15:36:50 2008 +0200
+++ b/MoinMoin/web/request.py	Sat Jun 28 17:20:18 2008 +0200
@@ -51,3 +51,16 @@
     def in_data(self):
         return self.in_stream.read()
     in_data = cached_property(in_data, doc=WerkzeugRequest.data.__doc__)
+
+def create_request(pagename='/'):
+    """
+    Creates an environment for a local request and returns the  already
+    intialized Request-object
+    """
+    from werkzeug.utils import create_environ
+    if not pagename.startswith('/'):
+        pagename = '/' + pagename
+    environ = create_environ(path=pagename)
+    environ['HTTP_USER_AGENT'] = 'CLI/Script'
+    return Request(environ)
+