Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
747b61aa3253
Commit
1f2cb083
authored
Aug 27, 2021
by
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
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
cubicweb/devtools/httptest.py
View file @
747b61aa
...
...
@@ -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
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment