Module: check_mk
Branch: master
Commit: e803b715ad629379c98ceec1b8116d21e4662fa2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e803b715ad6293…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Jan 4 14:18:38 2019 +0100
Use WSGI environment helper from werkzeug.
Change-Id: I7abc6f2f23d004ca56f4c83a0ee6ef60cd1a66a5
---
tests/unit/cmk/gui/conftest.py | 17 +++++------------
tests/unit/cmk/gui/old/classes.py | 20 +++++---------------
2 files changed, 10 insertions(+), 27 deletions(-)
diff --git a/tests/unit/cmk/gui/conftest.py b/tests/unit/cmk/gui/conftest.py
index 5025b38..80c6342 100644
--- a/tests/unit/cmk/gui/conftest.py
+++ b/tests/unit/cmk/gui/conftest.py
@@ -1,10 +1,11 @@
import pytest
import _pytest
-import werkzeug.wrappers
+from werkzeug.test import create_environ
+from werkzeug.wrappers import Response
import cmk.gui.config as config
import cmk.gui.htmllib as htmllib
-import cmk.gui.http as http
+from cmk.gui.http import Request
from cmk.gui.globals import html
monkeypatch = _pytest.monkeypatch.MonkeyPatch()
@@ -14,13 +15,5 @@ monkeypatch.setattr(config, "omd_site", lambda:
"NO_SITE")
@pytest.fixture()
def register_builtin_html():
"""This fixture registers a global htmllib.html() instance just like
the regular GUI"""
- wsgi_environ = {
- # TODO: This is no complete WSGI environment. Produce some
- "wsgi.input": "",
- "SCRIPT_NAME": "",
- "REQUEST_URI": "",
- }
- request = http.Request(wsgi_environ)
- response = werkzeug.wrappers.Response()
-
- html.set_current(htmllib.html(request, response))
+ environ = dict(create_environ(), REQUEST_URI='')
+ html.set_current(htmllib.html(Request(environ), Response()))
diff --git a/tests/unit/cmk/gui/old/classes.py b/tests/unit/cmk/gui/old/classes.py
index 6b899c4..2d2fa72 100644
--- a/tests/unit/cmk/gui/old/classes.py
+++ b/tests/unit/cmk/gui/old/classes.py
@@ -2,27 +2,17 @@
# call using
# > py.test -s -k test_html_generator.py
-import re
-import json
-import traceback
+from werkzeug.test import create_environ
+from werkzeug.wrappers import Response
-import werkzeug.wrappers
-
-import cmk.gui.http as http
+from cmk.gui.http import Request
import cmk.gui.htmllib as htmllib
# A Class which can be used to simulate HTML generation in varios tests in tests/web/
class HTMLTester(htmllib.html):
def __init__(self):
- wsgi_environ = {
- # TODO: This is no complete WSGI environment. Produce some
- "wsgi.input" : "",
- "SCRIPT_NAME" : "",
- }
- request = http.Request(wsgi_environ)
- response = werkzeug.wrappers.Response()
-
- super(HTMLTester, self).__init__(request, response)
+ environ = dict(create_environ(), REQUEST_URI='')
+ super(HTMLTester, self).__init__(Request(environ), Response())
def context_button_test(obj, title, url, icon=None, hot=False, id_=None, bestof=None,
hover_title=None, id_in_best=False):