|
5 | 5 | from typing import Any, Final |
6 | 6 |
|
7 | 7 | import pytest |
8 | | -from playwright.sync_api import Page |
| 8 | +from playwright.sync_api import APIRequestContext, Page |
9 | 9 | from pydantic import AnyUrl |
10 | 10 | from pytest_simcore.helpers.logging_tools import log_context |
11 | 11 | from pytest_simcore.helpers.playwright import ( |
|
25 | 25 |
|
26 | 26 |
|
27 | 27 | @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 | + |
29 | 35 | def _create_function_from_project( |
30 | 36 | page: Page, |
31 | 37 | project_uuid: str, |
@@ -55,11 +61,24 @@ def _create_function_from_project( |
55 | 61 | "Created function: %s", f"{json.dumps(function_data['data'], indent=2)}" |
56 | 62 | ) |
57 | 63 |
|
| 64 | + page.click("body") # to close any dialog |
| 65 | + created_function_uuids.append(function_data["data"]["uuid"]) |
58 | 66 | return function_data["data"] |
59 | 67 |
|
60 | 68 | yield _create_function_from_project |
61 | 69 |
|
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()}'" |
63 | 82 |
|
64 | 83 |
|
65 | 84 | def test_response_surface_modeling( |
|
0 commit comments