2525from pytest import Item
2626from pytest_simcore .helpers .logging_tools import log_context
2727from pytest_simcore .helpers .playwright import (
28- SECOND ,
2928 MINUTE ,
29+ SECOND ,
3030 AutoRegisteredUser ,
3131 RunningState ,
3232 ServiceType ,
@@ -78,6 +78,12 @@ def pytest_addoption(parser: pytest.Parser) -> None:
7878 default = False ,
7979 help = "Whether product is billable or not" ,
8080 )
81+ group .addoption (
82+ "--product-lite" ,
83+ action = "store_true" ,
84+ default = False ,
85+ help = "Whether product is lite version or not" ,
86+ )
8187 group .addoption (
8288 "--autoscaled" ,
8389 action = "store_true" ,
@@ -224,13 +230,19 @@ def user_password(
224230
225231
226232@pytest .fixture (scope = "session" )
227- def product_billable (request : pytest .FixtureRequest ) -> bool :
233+ def is_product_billable (request : pytest .FixtureRequest ) -> bool :
228234 billable = request .config .getoption ("--product-billable" )
229235 return TypeAdapter (bool ).validate_python (billable )
230236
231237
232238@pytest .fixture (scope = "session" )
233- def autoscaled (request : pytest .FixtureRequest ) -> bool :
239+ def is_product_lite (request : pytest .FixtureRequest ) -> bool :
240+ enabled = request .config .getoption ("--product-lite" )
241+ return TypeAdapter (bool ).validate_python (enabled )
242+
243+
244+ @pytest .fixture (scope = "session" )
245+ def is_autoscaled (request : pytest .FixtureRequest ) -> bool :
234246 autoscaled = request .config .getoption ("--autoscaled" )
235247 return TypeAdapter (bool ).validate_python (autoscaled )
236248
@@ -388,7 +400,7 @@ def log_in_and_out(
388400def create_new_project_and_delete (
389401 page : Page ,
390402 log_in_and_out : WebSocket ,
391- product_billable : bool ,
403+ is_product_billable : bool ,
392404 api_request_context : APIRequestContext ,
393405 product_url : AnyUrl ,
394406) -> Iterator [Callable [[tuple [RunningState ], bool ], dict [str , Any ]]]:
@@ -407,15 +419,20 @@ def _(
407419 ), "misuse of this fixture! only 1 study can be opened at a time. Otherwise please modify the fixture"
408420 with log_context (
409421 logging .INFO ,
410- f"Open project in { product_url = } as { product_billable = } " ,
422+ f"Open project in { product_url = } as { is_product_billable = } " ,
411423 ) as ctx :
412424 waiter = SocketIOProjectStateUpdatedWaiter (expected_states = expected_states )
413- timeout = _OPENING_TUTORIAL_MAX_WAIT_TIME if template_id is not None else _OPENING_NEW_EMPTY_PROJECT_MAX_WAIT_TIME
425+ timeout = (
426+ _OPENING_TUTORIAL_MAX_WAIT_TIME
427+ if template_id is not None
428+ else _OPENING_NEW_EMPTY_PROJECT_MAX_WAIT_TIME
429+ )
414430 with (
415- log_in_and_out .expect_event ("framereceived" , waiter , timeout = timeout + 10 * SECOND ),
431+ log_in_and_out .expect_event (
432+ "framereceived" , waiter , timeout = timeout + 10 * SECOND
433+ ),
416434 page .expect_response (
417- re .compile (r"/projects/[^:]+:open" ),
418- timeout = timeout + 5 * SECOND
435+ re .compile (r"/projects/[^:]+:open" ), timeout = timeout + 5 * SECOND
419436 ) as response_info ,
420437 ):
421438 # Project detail view pop-ups shows
@@ -436,8 +453,11 @@ def _(
436453 # From the long running tasks response's urls, only their path is relevant
437454 def url_to_path (url ):
438455 return urllib .parse .urlparse (url ).path
456+
439457 def wait_for_done (response ):
440- if url_to_path (response .url ) == url_to_path (lrt_data ["status_href" ]):
458+ if url_to_path (response .url ) == url_to_path (
459+ lrt_data ["status_href" ]
460+ ):
441461 resp_data = response .json ()
442462 resp_data = resp_data ["data" ]
443463 assert "task_progress" in resp_data
@@ -448,17 +468,20 @@ def wait_for_done(response):
448468 task_progress ["message" ],
449469 )
450470 return False
451- if url_to_path (response .url ) == url_to_path (lrt_data ["result_href" ]):
471+ if url_to_path (response .url ) == url_to_path (
472+ lrt_data ["result_href" ]
473+ ):
452474 copying_logger .logger .info ("project created" )
453475 return response .status == 201
454476 return False
477+
455478 with page .expect_response (wait_for_done , timeout = timeout ):
456479 # if the above calls go to fast, this test could fail
457480 # not expected in the sim4life context though
458481 ...
459482 else :
460483 open_button .click ()
461- if product_billable :
484+ if is_product_billable :
462485 # Open project with default resources
463486 page .get_by_test_id ("openWithResources" ).click ()
464487 project_data = response_info .value .json ()
@@ -497,7 +520,7 @@ def wait_for_done(response):
497520 for project_uuid in created_project_uuids :
498521 with log_context (
499522 logging .INFO ,
500- f"Delete project with { project_uuid = } in { product_url = } as { product_billable = } " ,
523+ f"Delete project with { project_uuid = } in { product_url = } as { is_product_billable = } " ,
501524 ):
502525 response = api_request_context .delete (
503526 f"{ product_url } v0/projects/{ project_uuid } "
0 commit comments