@@ -112,6 +112,13 @@ def pytest_addoption(parser: pytest.Parser) -> None:
112
112
default = False ,
113
113
help = "Whether service is a legacy service (no sidecar)" ,
114
114
)
115
+ group .addoption (
116
+ "--service-version" ,
117
+ action = "store" ,
118
+ type = str ,
119
+ default = None ,
120
+ help = "The service version option defines a service specific version" ,
121
+ )
115
122
group .addoption (
116
123
"--template-id" ,
117
124
action = "store" ,
@@ -272,6 +279,14 @@ def is_service_legacy(request: pytest.FixtureRequest) -> bool:
272
279
return TypeAdapter (bool ).validate_python (autoscaled )
273
280
274
281
282
+ @pytest .fixture (scope = "session" )
283
+ def service_version (request : pytest .FixtureRequest ) -> str | None :
284
+ if key := request .config .getoption ("--service-version" ):
285
+ assert isinstance (key , str )
286
+ return key
287
+ return None
288
+
289
+
275
290
@pytest .fixture (scope = "session" )
276
291
def template_id (request : pytest .FixtureRequest ) -> str | None :
277
292
if key := request .config .getoption ("--template-id" ):
@@ -438,13 +453,25 @@ def _open_with_resources(page: Page, *, click_it: bool):
438
453
return open_with_resources_button
439
454
440
455
456
+ def _select_service_version (page : Page , * , version : str ) -> None :
457
+ try :
458
+ # since https://github.com/ITISFoundation/osparc-simcore/pull/7060
459
+ page .get_by_test_id ("serviceSelectBox" , timeout = 5 * SECOND ).select_option (
460
+ version
461
+ )
462
+ except TimeoutError :
463
+ # we try the non robust way
464
+ page .get_by_label ("Version" ).select_option (version )
465
+
466
+
441
467
@pytest .fixture
442
468
def create_new_project_and_delete (
443
469
page : Page ,
444
470
log_in_and_out : RestartableWebSocket ,
445
471
is_product_billable : bool ,
446
472
api_request_context : APIRequestContext ,
447
473
product_url : AnyUrl ,
474
+ service_version : str | None ,
448
475
) -> Iterator [Callable [[tuple [RunningState ], bool ], dict [str , Any ]]]:
449
476
"""The first available service currently displayed in the dashboard will be opened
450
477
NOTE: cannot be used multiple times or going back to dashboard will fail!!
@@ -453,12 +480,13 @@ def create_new_project_and_delete(
453
480
454
481
def _ (
455
482
expected_states : tuple [RunningState ] = (RunningState .NOT_STARTED ,),
483
+ * ,
456
484
press_open : bool = True ,
457
485
template_id : str | None = None ,
458
486
) -> dict [str , Any ]:
459
- assert (
460
- len ( created_project_uuids ) == 0
461
- ), "misuse of this fixture! only 1 study can be opened at a time. Otherwise please modify the fixture"
487
+ assert len ( created_project_uuids ) == 0 , (
488
+ "misuse of this fixture! only 1 study can be opened at a time. Otherwise please modify the fixture"
489
+ )
462
490
with log_context (
463
491
logging .INFO ,
464
492
f"Open project in { product_url = } as { is_product_billable = } " ,
@@ -479,6 +507,8 @@ def _(
479
507
):
480
508
open_with_resources_clicked = False
481
509
# Project detail view pop-ups shows
510
+ if service_version is not None :
511
+ _select_service_version (page , version = service_version )
482
512
if press_open :
483
513
open_button = page .get_by_test_id ("openResource" )
484
514
if template_id is not None :
@@ -573,9 +603,9 @@ def wait_for_done(response):
573
603
response = api_request_context .delete (
574
604
f"{ product_url } v0/projects/{ project_uuid } "
575
605
)
576
- assert (
577
- response . status == 204
578
- ), f"Unexpected error while deleting project: ' { response . json () } '"
606
+ assert response . status == 204 , (
607
+ f"Unexpected error while deleting project: ' { response . json () } '"
608
+ )
579
609
580
610
581
611
# SEE https://github.com/ITISFoundation/osparc-simcore/pull/5618#discussion_r1553943415
@@ -644,7 +674,7 @@ def create_project_from_new_button(
644
674
def _ (plus_button_test_id : str ) -> dict [str , Any ]:
645
675
start_study_from_plus_button (plus_button_test_id )
646
676
expected_states = (RunningState .UNKNOWN ,)
647
- return create_new_project_and_delete (expected_states , False )
677
+ return create_new_project_and_delete (expected_states , press_open = False )
648
678
649
679
return _
650
680
@@ -657,7 +687,9 @@ def create_project_from_template_dashboard(
657
687
def _ (template_id : str ) -> dict [str , Any ]:
658
688
find_and_click_template_in_dashboard (template_id )
659
689
expected_states = (RunningState .UNKNOWN ,)
660
- return create_new_project_and_delete (expected_states , True , template_id )
690
+ return create_new_project_and_delete (
691
+ expected_states , press_open = True , template_id = template_id
692
+ )
661
693
662
694
return _
663
695
@@ -676,7 +708,7 @@ def _(
676
708
expected_states = (RunningState .UNKNOWN ,)
677
709
if service_type is ServiceType .COMPUTATIONAL :
678
710
expected_states = (RunningState .NOT_STARTED ,)
679
- return create_new_project_and_delete (expected_states , True )
711
+ return create_new_project_and_delete (expected_states , press_open = True )
680
712
681
713
return _
682
714
0 commit comments