Skip to content

Commit 0710eda

Browse files
committed
create and delete functions now
1 parent e58518c commit 0710eda

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

tests/e2e-playwright/tests/metamodeling/test_response_surface_modeling.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import Any, Final
66

77
import pytest
8-
from playwright.sync_api import Page
8+
from playwright.sync_api import APIRequestContext, Page
99
from pydantic import AnyUrl
1010
from pytest_simcore.helpers.logging_tools import log_context
1111
from pytest_simcore.helpers.playwright import (
@@ -25,7 +25,13 @@
2525

2626

2727
@pytest.fixture
28-
def create_function_from_project() -> Iterator[Callable[[Page, str], dict[str, Any]]]:
28+
def create_function_from_project(
29+
api_request_context: APIRequestContext,
30+
is_product_billable: bool,
31+
product_url: AnyUrl,
32+
) -> Iterator[Callable[[Page, str], dict[str, Any]]]:
33+
created_function_uuids: list[str] = []
34+
2935
def _create_function_from_project(
3036
page: Page,
3137
project_uuid: str,
@@ -55,11 +61,24 @@ def _create_function_from_project(
5561
"Created function: %s", f"{json.dumps(function_data['data'], indent=2)}"
5662
)
5763

64+
page.click("body") # to close any dialog
65+
created_function_uuids.append(function_data["data"]["uuid"])
5866
return function_data["data"]
5967

6068
yield _create_function_from_project
6169

62-
# cleanup the function
70+
# cleanup the functions
71+
for function_uuid in created_function_uuids:
72+
with log_context(
73+
logging.INFO,
74+
f"Delete function with {function_uuid=} in {product_url=} as {is_product_billable=}",
75+
):
76+
response = api_request_context.delete(
77+
f"{product_url}v0/functions/{function_uuid}"
78+
)
79+
assert (
80+
response.status == 204
81+
), f"Unexpected error while deleting project: '{response.json()}'"
6382

6483

6584
def test_response_surface_modeling(

0 commit comments

Comments
 (0)