Skip to content

Commit d8f17bd

Browse files
committed
adds --product-billable
1 parent 1b6f126 commit d8f17bd

File tree

5 files changed

+50
-24
lines changed

5 files changed

+50
-24
lines changed

tests/e2e-playwright/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ define run_test
168168
pytest -s $2 \
169169
--color=yes \
170170
--browser chromium \
171-
--headed \
172171
$$TEST_ARGS
173172
endef
174173

tests/e2e-playwright/tests/conftest.py

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
from pytest import Item
2626
from pytest_simcore.helpers.logging_tools import log_context
2727
from 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(
388400
def 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}"

tests/e2e-playwright/tests/sim4life/test_sim4life.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def test_sim4life(
2828
log_in_and_out: WebSocket,
2929
service_key: str,
3030
use_plus_button: bool,
31-
autoscaled: bool,
31+
is_autoscaled: bool,
3232
check_videostreaming: bool,
3333
):
3434
if use_plus_button:
@@ -46,7 +46,11 @@ def test_sim4life(
4646
assert len(node_ids) == 1, "Expected 1 node in the workbench!"
4747

4848
resp = wait_for_launched_s4l(
49-
page, node_ids[0], log_in_and_out, autoscaled=autoscaled, copy_workspace=False
49+
page,
50+
node_ids[0],
51+
log_in_and_out,
52+
autoscaled=is_autoscaled,
53+
copy_workspace=False,
5054
)
5155
s4l_websocket = resp["websocket"]
5256
s4l_iframe = resp["iframe"]

tests/e2e-playwright/tests/sim4life/test_template.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_template(
2323
create_project_from_template_dashboard: Callable[[str], dict[str, Any]],
2424
log_in_and_out: WebSocket,
2525
template_id: str,
26-
autoscaled: bool,
26+
is_autoscaled: bool,
2727
check_videostreaming: bool,
2828
):
2929
project_data = create_project_from_template_dashboard(template_id)
@@ -36,7 +36,7 @@ def test_template(
3636
assert len(node_ids) == 1, "Expected 1 node in the workbench!"
3737

3838
resp = wait_for_launched_s4l(
39-
page, node_ids[0], log_in_and_out, autoscaled=autoscaled, copy_workspace=True
39+
page, node_ids[0], log_in_and_out, autoscaled=is_autoscaled, copy_workspace=True
4040
)
4141
s4l_websocket = resp["websocket"]
4242
s4l_iframe = resp["iframe"]

tests/e2e-playwright/tests/tip/test_ti_plan.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ def __call__(self, message: str) -> bool:
8686
return False
8787

8888

89-
def test_tip( # noqa: PLR0915
89+
def test_classic_ti_plan( # noqa: PLR0915
9090
page: Page,
9191
create_tip_plan_from_dashboard: Callable[[str], dict[str, Any]],
9292
log_in_and_out: WebSocket,
93-
autoscaled: bool,
93+
is_autoscaled: bool,
9494
):
9595
project_data = create_tip_plan_from_dashboard("newTIPlanButton")
9696
assert "workbench" in project_data, "Expected workbench to be in project data!"
@@ -108,7 +108,7 @@ def test_tip( # noqa: PLR0915
108108
websocket=log_in_and_out,
109109
timeout=(
110110
_ELECTRODE_SELECTOR_AUTOSCALED_MAX_STARTUP_TIME
111-
if autoscaled
111+
if is_autoscaled
112112
else _ELECTRODE_SELECTOR_MAX_STARTUP_TIME
113113
),
114114
press_start_button=False,
@@ -155,7 +155,7 @@ def test_tip( # noqa: PLR0915
155155
timeout=_OUTER_EXPECT_TIMEOUT_RATIO
156156
* (
157157
_JLAB_AUTOSCALED_MAX_STARTUP_TIME
158-
if autoscaled
158+
if is_autoscaled
159159
else _JLAB_MAX_STARTUP_MAX_TIME
160160
),
161161
) as ws_info:
@@ -165,7 +165,7 @@ def test_tip( # noqa: PLR0915
165165
websocket=log_in_and_out,
166166
timeout=(
167167
_JLAB_AUTOSCALED_MAX_STARTUP_TIME
168-
if autoscaled
168+
if is_autoscaled
169169
else _JLAB_MAX_STARTUP_MAX_TIME
170170
),
171171
press_start_button=False,
@@ -218,7 +218,7 @@ def test_tip( # noqa: PLR0915
218218
websocket=log_in_and_out,
219219
timeout=(
220220
_POST_PRO_AUTOSCALED_MAX_STARTUP_TIME
221-
if autoscaled
221+
if is_autoscaled
222222
else _POST_PRO_MAX_STARTUP_TIME
223223
),
224224
press_start_button=False,

0 commit comments

Comments
 (0)