Fix pyramid test_login.py
The login page is supposed to redirect to the initial page the user wanted to see.
This feature was broken and now fixed, but some errors still persist in the py3-pyramid tests (cubicweb/pyramid/test/test_login.py
).
These errors should be fixed.
Traceback:
=================================== FAILURES ===================================
_______ LoginRedirectionTC.test_redirect_to_cubicweb_page_with_arguments _______
self = <cubicweb.pyramid.test.test_login.LoginRedirectionTC testMethod=test_redirect_to_cubicweb_page_with_arguments>
def test_redirect_to_cubicweb_page_with_arguments(self):
> res = self.webapp.get("/cwsource?args=42", status=303)
cubicweb/pyramid/test/test_login.py:60:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3-pyramid/lib/python3.9/site-packages/webtest/app.py:324: in get
return self.do_request(req, status=status,
.tox/py3-pyramid/lib/python3.9/site-packages/webtest/app.py:646: in do_request
self._check_status(status, res)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <cubicweb.pyramid.test.TestApp object at 0x7fb092b0c9a0>, status = 303
res = <404 Not Found text/plain body=b'404 Not ...\n\n'/61>
def _check_status(self, status, res):
if status == '*':
return
res_status = res.status
if (isinstance(status, str) and '*' in status):
if re.match(fnmatch.translate(status), res_status, re.I):
return
if isinstance(status, str):
if status == res_status:
return
if isinstance(status, (list, tuple)):
if res.status_int not in status:
raise AppError(
"Bad response: %s (not one of %s for %s)\n%s",
res_status, ', '.join(map(str, status)),
res.request.url, res)
return
if status is None:
if res.status_int >= 200 and res.status_int < 400:
return
raise AppError(
"Bad response: %s (not 200 OK or 3xx redirect for %s)\n%s",
res_status, res.request.url,
res)
if status != res.status_int:
> raise AppError(
"Bad response: %s (not %s)\n%s", res_status, status, res)
E webtest.app.AppError: Bad response: 404 Not Found (not 303)
E 404 Not Found
E
E The resource could not be found.
E
E
E /cwsource
.tox/py3-pyramid/lib/python3.9/site-packages/webtest/app.py:680: AppError
----------------------------- Captured stdout call -----------------------------
2022-09-07 09:45:12 - "GET /cwsource HTTP/1.0" 404 0
----------------------------- Captured stderr call -----------------------------
2022-09-07 09:45:12 - (cubicweb.repository.pool) DEBUG: [pool] try to get a connection, free queue size is 1/1 (max 0)
2022-09-07 09:45:12 - (cubicweb.repository.pool) DEBUG: [pool] we got a directly available connection
2022-09-07 09:45:12 - (logilab.database) INFO: connecting to /builds/cubicweb/cubicweb/cubicweb/pyramid/test/data/database/tmpdb108@localhost for user admin
2022-09-07 09:45:12 - (cubicweb.repository.pool) DEBUG: [pool] release <cubicweb.server.sqlutils.SqliteConnectionWrapper object at 0x7fb092dfb3a0> [140396355105696], free queue size is 1/1 (max 0)
2022-09-07 09:45:12 - (cubicweb.pyramid.security.csrf) DEBUG: generate a new CSRF token
Traceback (most recent call last):
File "/builds/cubicweb/cubicweb/cubicweb/pyramid/debug.py", line 23, in __call__
response = self.handler(request)
File "/builds/cubicweb/cubicweb/cubicweb/pyramid/defaults.py", line 40, in __call__
return self._handler(request)
File "/builds/cubicweb/cubicweb/.tox/py3-pyramid/lib/python3.9/site-packages/pyramid/router.py", line 173, in handle_request
raise HTTPNotFound(msg)
pyramid.httpexceptions.HTTPNotFound: /cwsource
_____ LoginRedirectionTC.test_redirect_to_cubicweb_page_without_arguments ______
self = <cubicweb.pyramid.test.test_login.LoginRedirectionTC testMethod=test_redirect_to_cubicweb_page_without_arguments>
def test_redirect_to_cubicweb_page_without_arguments(self):
> res = self.webapp.get("/cwsource", status=303)
cubicweb/pyramid/test/test_login.py:64:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3-pyramid/lib/python3.9/site-packages/webtest/app.py:324: in get
return self.do_request(req, status=status,
.tox/py3-pyramid/lib/python3.9/site-packages/webtest/app.py:646: in do_request
self._check_status(status, res)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <cubicweb.pyramid.test.TestApp object at 0x7fb092cd7e20>, status = 303
res = <404 Not Found text/plain body=b'404 Not ...\n\n'/61>
def _check_status(self, status, res):
if status == '*':
return
res_status = res.status
if (isinstance(status, str) and '*' in status):
if re.match(fnmatch.translate(status), res_status, re.I):
return
if isinstance(status, str):
if status == res_status:
return
if isinstance(status, (list, tuple)):
if res.status_int not in status:
raise AppError(
"Bad response: %s (not one of %s for %s)\n%s",
res_status, ', '.join(map(str, status)),
res.request.url, res)
return
if status is None:
if res.status_int >= 200 and res.status_int < 400:
return
raise AppError(
"Bad response: %s (not 200 OK or 3xx redirect for %s)\n%s",
res_status, res.request.url,
res)
if status != res.status_int:
> raise AppError(
"Bad response: %s (not %s)\n%s", res_status, status, res)
E webtest.app.AppError: Bad response: 404 Not Found (not 303)
E 404 Not Found
E
E The resource could not be found.
E
E
E /cwsource
.tox/py3-pyramid/lib/python3.9/site-packages/webtest/app.py:680: AppError
----------------------------- Captured stdout call -----------------------------
2022-09-07 09:45:13 - "GET /cwsource HTTP/1.0" 404 0
----------------------------- Captured stderr call -----------------------------
2022-09-07 09:45:13 - (cubicweb.repository.pool) DEBUG: [pool] try to get a connection, free queue size is 1/1 (max 0)
2022-09-07 09:45:13 - (cubicweb.repository.pool) DEBUG: [pool] we got a directly available connection
2022-09-07 09:45:13 - (logilab.database) INFO: connecting to /builds/cubicweb/cubicweb/cubicweb/pyramid/test/data/database/tmpdb108@localhost for user admin
2022-09-07 09:45:13 - (cubicweb.repository.pool) DEBUG: [pool] release <cubicweb.server.sqlutils.SqliteConnectionWrapper object at 0x7fb092dfb3a0> [140396355105696], free queue size is 1/1 (max 0)
2022-09-07 09:45:13 - (cubicweb.pyramid.security.csrf) DEBUG: generate a new CSRF token
Traceback (most recent call last):
File "/builds/cubicweb/cubicweb/cubicweb/pyramid/debug.py", line 23, in __call__
response = self.handler(request)
File "/builds/cubicweb/cubicweb/cubicweb/pyramid/defaults.py", line 40, in __call__
return self._handler(request)
File "/builds/cubicweb/cubicweb/.tox/py3-pyramid/lib/python3.9/site-packages/pyramid/router.py", line 173, in handle_request
raise HTTPNotFound(msg)
pyramid.httpexceptions.HTTPNotFound: /cwsource
_________ LoginRedirectionTC.test_redirect_to_main_page_with_arguments _________
self = <cubicweb.pyramid.test.test_login.LoginRedirectionTC testMethod=test_redirect_to_main_page_with_arguments>
def test_redirect_to_main_page_with_arguments(self):
> res = self.webapp.get("/?args=42", status=303)
cubicweb/pyramid/test/test_login.py:68:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3-pyramid/lib/python3.9/site-packages/webtest/app.py:324: in get
return self.do_request(req, status=status,
.tox/py3-pyramid/lib/python3.9/site-packages/webtest/app.py:646: in do_request
self._check_status(status, res)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <cubicweb.pyramid.test.TestApp object at 0x7fb092c75160>, status = 303
res = <200 OK text/html body=b'Congratu...ing!'/35>
def _check_status(self, status, res):
if status == '*':
return
res_status = res.status
if (isinstance(status, str) and '*' in status):
if re.match(fnmatch.translate(status), res_status, re.I):
return
if isinstance(status, str):
if status == res_status:
return
if isinstance(status, (list, tuple)):
if res.status_int not in status:
raise AppError(
"Bad response: %s (not one of %s for %s)\n%s",
res_status, ', '.join(map(str, status)),
res.request.url, res)
return
if status is None:
if res.status_int >= 200 and res.status_int < 400:
return
raise AppError(
"Bad response: %s (not 200 OK or 3xx redirect for %s)\n%s",
res_status, res.request.url,
res)
if status != res.status_int:
> raise AppError(
"Bad response: %s (not %s)\n%s", res_status, status, res)
E webtest.app.AppError: Bad response: 200 OK (not 303)
E Congratulation CubicWeb is running!
.tox/py3-pyramid/lib/python3.9/site-packages/webtest/app.py:680: AppError