tests: adapt initialization after django switch
This commit is contained in:
parent
0582458222
commit
3cae8f261a
|
@ -3,33 +3,45 @@ import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from webtest import TestApp
|
from webtest import TestApp
|
||||||
from quixote.wsgi import QWIP
|
from quixote import cleanup, get_publisher
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
from qommon.publisher import set_publisher_class
|
from qommon.publisher import set_publisher_class
|
||||||
import wcs
|
import wcs
|
||||||
import publisher
|
import wcs.wsgi
|
||||||
from wcs.qommon.http_request import HTTPRequest
|
from wcs.qommon.http_request import HTTPRequest
|
||||||
|
from wcs import publisher, compat
|
||||||
|
|
||||||
QWIP.request_class = HTTPRequest
|
import wcs.middleware
|
||||||
|
|
||||||
|
wcs.middleware.AfterJobsMiddleware.ASYNC = False
|
||||||
|
|
||||||
def create_temporary_pub():
|
def create_temporary_pub():
|
||||||
config = ConfigParser.ConfigParser()
|
config = ConfigParser.ConfigParser()
|
||||||
APP_DIR = tempfile.mkdtemp()
|
APP_DIR = tempfile.mkdtemp()
|
||||||
set_publisher_class(publisher.WcsPublisher)
|
compat.CompatWcsPublisher.APP_DIR = APP_DIR
|
||||||
publisher.WcsPublisher.APP_DIR = APP_DIR
|
compat.CompatWcsPublisher.DATA_DIR = os.path.abspath(
|
||||||
publisher.WcsPublisher.DATA_DIR = os.path.abspath(
|
|
||||||
os.path.join(os.path.dirname(wcs.__file__), '..', 'data'))
|
os.path.join(os.path.dirname(wcs.__file__), '..', 'data'))
|
||||||
|
compat.CompatWcsPublisher.cronjobs = None
|
||||||
config.add_section('extra')
|
config.add_section('extra')
|
||||||
config.set('extra', 'auquotidien', os.path.join(os.path.dirname(__file__), '..', 'auquotidien'))
|
config.set('extra', 'auquotidien', os.path.join(os.path.dirname(__file__), '..', 'auquotidien'))
|
||||||
publisher.WcsPublisher.configure(config)
|
compat.CompatWcsPublisher._initialized = False
|
||||||
pub = publisher.WcsPublisher.create_publisher()
|
compat.CompatWcsPublisher.configure(config)
|
||||||
|
compat.CompatWcsPublisher.init_publisher_class()
|
||||||
|
pub = compat.CompatWcsPublisher.create_publisher()
|
||||||
# allow saving the user
|
# allow saving the user
|
||||||
pub.app_dir = os.path.join(APP_DIR, 'example.net')
|
pub.app_dir = os.path.join(APP_DIR, 'example.net')
|
||||||
os.mkdir(pub.app_dir)
|
os.mkdir(pub.app_dir)
|
||||||
return pub
|
return pub
|
||||||
|
|
||||||
def get_app(pub):
|
def get_app(pub, https=False):
|
||||||
return TestApp(QWIP(pub), extra_environ={'HTTP_HOST': 'example.net'})
|
extra_environ = {'HTTP_HOST': 'example.net', 'REMOTE_ADDR': '127.0.0.1'}
|
||||||
|
if https:
|
||||||
|
settings.SECURE_PROXY_SSL_HEADER = ('HTTPS', 'on')
|
||||||
|
extra_environ['HTTPS'] = 'on'
|
||||||
|
else:
|
||||||
|
extra_environ['HTTPS'] = 'off'
|
||||||
|
return TestApp(wcs.wsgi.application, extra_environ=extra_environ)
|
||||||
|
|
||||||
def login(app, username='admin', password='admin'):
|
def login(app, username='admin', password='admin'):
|
||||||
login_page = app.get('/login/')
|
login_page = app.get('/login/')
|
||||||
|
|
Reference in New Issue