changeset 6630:d4e1692e25ab

tests: introduce webserver fixture To be used for tests that actually access a running web server - especially to make the manual vcs tests less manual.
author domruf <dominikruf@gmail.com>
date Mon, 02 May 2016 22:41:51 +0200
parents 3af2dea756db
children d7cdef68240b
files dev_requirements.txt kallithea/tests/conftest.py
diffstat 2 files changed, 17 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/dev_requirements.txt	Mon May 01 17:23:31 2017 +0200
+++ b/dev_requirements.txt	Mon May 02 22:41:51 2016 +0200
@@ -4,6 +4,7 @@
 pytest-runner
 pytest-sugar>=0.7.0
 pytest-catchlog
+pytest-localserver
 mock
 sphinx
 webtest < 3
--- a/kallithea/tests/conftest.py	Mon May 01 17:23:31 2017 +0200
+++ b/kallithea/tests/conftest.py	Mon May 02 22:41:51 2016 +0200
@@ -5,15 +5,17 @@
 
 from paste.deploy import loadwsgi
 from routes.util import URLGenerator
+import pytest
+from pytest_localserver.http import WSGIServer
 
-import pytest
 from kallithea.controllers.root import RootController
 from kallithea.lib.utils import repo2db_mapper
 from kallithea.model.user import UserModel
 from kallithea.model.meta import Session
 from kallithea.model.db import Setting, User, UserIpMap
 from kallithea.model.scm import ScmModel
-from kallithea.tests.base import invalidate_all_caches, TEST_USER_REGULAR_LOGIN, TESTS_TMP_PATH
+from kallithea.tests.base import invalidate_all_caches, TEST_USER_REGULAR_LOGIN, TESTS_TMP_PATH, \
+    TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS
 import kallithea.tests.base # FIXME: needed for setting testapp instance!!!
 
 from tg.util.webtest import test_context
@@ -142,3 +144,15 @@
     """
     with test_context(app_fixture):
         yield
+
+
+@pytest.yield_fixture(scope="session")
+def webserver():
+    """Start web server while tests are running.
+    Useful for debugging and necessary for vcs operation tests."""
+    server = WSGIServer(application=kallithea.tests.base.testapp)
+    server.start()
+
+    yield server
+
+    server.stop()