Skip to content

Commit f2c331c

Browse files
committed
improves assert
1 parent 2c6e689 commit f2c331c

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

services/web/server/tests/unit/with_dbs/04/studies_dispatcher/test_studies_dispatcher_studies_access.py

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,24 @@ async def _assert_redirected_to_study(
234234
"OSPARC-SIMCORE" in content
235235
), f"Expected front-end rendering workbench's study, got {content!s}"
236236

237-
# Expects fragment to indicate client where to find newly created project
238-
m = re.match(r"/study/([\d\w-]+)", response.real_url.fragment)
239-
assert m, f"Expected /study/uuid, got {response.real_url.fragment}"
237+
# First check if the fragment indicates an error
238+
fragment = response.real_url.fragment
239+
error_match = re.match(r"/error", fragment)
240+
if error_match:
241+
# Parse query parameters to extract error details
242+
query_params = urllib.parse.parse_qs(
243+
fragment.split("?", 1)[1] if "?" in fragment else ""
244+
)
245+
error_message = query_params.get("message", ["Unknown error"])[0]
246+
error_status = query_params.get("status_code", ["Unknown"])[0]
247+
248+
pytest.fail(
249+
f"Redirected to error page: Status={error_status}, Message={error_message}"
250+
)
251+
252+
# Check for study path if not an error
253+
m = re.match(r"/study/([\d\w-]+)", fragment)
254+
assert m, f"Expected /study/uuid, got {fragment}"
240255

241256
# Expects auth cookie for current user
242257
assert _is_user_authenticated(session)

0 commit comments

Comments
 (0)