Commit 1f2cb083 authored by Laurent Peuch's avatar Laurent Peuch
Browse files

refactor(CubicWebServerTC): merge _CubicWebServerTC into CubicWebServerTC

--HG--
branch : 3.32
parent d4bdca128aee
Pipeline #78896 failed with stages
in 108 minutes and 38 seconds
......@@ -58,17 +58,34 @@ def get_available_port(ports_scan):
)
class _CubicWebServerTC(_BasePyramidCWTest):
class CubicWebServerTC(_BasePyramidCWTest):
"""Base class for running a test web server."""
ports_range = range(7000, 8000)
def start_server(self):
raise NotImplementedError
app = self._generate_pyramid_config().make_wsgi_app()
self.httpd = StopableWSGIServer.create(app, port=self.config["port"])
self.httpd.wait()
parseurl = urlparse(self.config["base-url"])
assert parseurl.port == self.config["port"], (
self.config["base-url"],
self.config["port"],
)
self._web_test_cnx = http.client.HTTPConnection(
parseurl.hostname, parseurl.port
)
self._ident_cookie = None
def stop_server(self, timeout=15):
"""Stop the webserver, waiting for the thread to return"""
raise NotImplementedError
if self._web_test_cnx is None:
self.web_logout()
self._web_test_cnx.close()
self.httpd.shutdown()
def web_login(self, user=None, passwd=None):
"""Log the current http session for the provided credential
......@@ -123,29 +140,3 @@ class _CubicWebServerTC(_BasePyramidCWTest):
def tearDown(self):
self.stop_server()
super().tearDown()
class CubicWebServerTC(_CubicWebServerTC):
def start_server(self):
app = self._generate_pyramid_config().make_wsgi_app()
self.httpd = StopableWSGIServer.create(app, port=self.config["port"])
self.httpd.wait()
parseurl = urlparse(self.config["base-url"])
assert parseurl.port == self.config["port"], (
self.config["base-url"],
self.config["port"],
)
self._web_test_cnx = http.client.HTTPConnection(
parseurl.hostname, parseurl.port
)
self._ident_cookie = None
def stop_server(self, timeout=15):
if self._web_test_cnx is None:
self.web_logout()
self._web_test_cnx.close()
self.httpd.shutdown()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment