|
17 | 17 | MyServiceGet, |
18 | 18 | MyServicesRpcBatchGet, |
19 | 19 | ) |
| 20 | +from models_library.api_schemas_webserver.projects import ProjectPatch |
| 21 | +from models_library.products import ProductName |
20 | 22 | from models_library.services_history import ServiceRelease |
21 | 23 | from pytest_mock import MockerFixture |
22 | 24 | from pytest_simcore.helpers.assert_checks import assert_status |
23 | 25 | from pytest_simcore.helpers.webserver_users import UserInfoDict |
24 | 26 | from servicelib.aiohttp import status |
25 | 27 | from servicelib.rabbitmq import RPCServerError |
26 | 28 | from simcore_service_webserver.db.models import UserRole |
| 29 | +from simcore_service_webserver.projects import _projects_service |
27 | 30 | from simcore_service_webserver.projects.models import ProjectDict |
28 | 31 | from yarl import URL |
29 | 32 |
|
@@ -334,7 +337,7 @@ async def test_accessible_for_one_service( |
334 | 337 | expected_url = client.app.router["get_project_services_access_for_gid"].url_for( |
335 | 338 | project_id=project_id |
336 | 339 | ) |
337 | | - assert URL(f"/v0/projects/{project_id}/nodes/-/services:access") == expected_url |
| 340 | + assert URL(f"/v0/projects/{project_id}/nodes/-/services") == expected_url |
338 | 341 |
|
339 | 342 | resp = await client.get( |
340 | 343 | f"/v0/projects/{project_id}/nodes/-/services:access?for_gid={for_gid}" |
@@ -590,3 +593,50 @@ async def test_get_project_services_service_unavailable( |
590 | 593 |
|
591 | 594 | assert error |
592 | 595 | assert not data |
| 596 | + |
| 597 | + |
| 598 | +@pytest.mark.parametrize("user_role", [UserRole.USER]) |
| 599 | +async def test_get_project_services_empty_project( |
| 600 | + client: TestClient, |
| 601 | + user_project: ProjectDict, |
| 602 | + mocker: MockerFixture, |
| 603 | + logged_user: UserInfoDict, |
| 604 | + default_product_name: ProductName, |
| 605 | +): |
| 606 | + # |
| 607 | + # Clear the project's workbench to make it empty |
| 608 | + # Update the project in the database to have an empty workbench |
| 609 | + await _projects_service.patch_project_for_user( |
| 610 | + client.app, |
| 611 | + user_id=logged_user["id"], |
| 612 | + project_uuid=user_project["uuid"], |
| 613 | + project_patch=ProjectPatch(workbench={}), |
| 614 | + product_name=default_product_name, |
| 615 | + client_session_id=None, |
| 616 | + ) |
| 617 | + |
| 618 | + mocker.patch( |
| 619 | + "simcore_service_webserver.catalog._service.catalog_rpc.batch_get_my_services", |
| 620 | + spec=True, |
| 621 | + side_effect=ValueError( |
| 622 | + "Bad request: cannot batch-get an empty list of name-ids" |
| 623 | + ), |
| 624 | + ) |
| 625 | + |
| 626 | + assert client.app |
| 627 | + |
| 628 | + project_id = user_project["uuid"] |
| 629 | + |
| 630 | + expected_url = client.app.router["get_project_services"].url_for( |
| 631 | + project_id=project_id |
| 632 | + ) |
| 633 | + assert URL(f"/v0/projects/{project_id}/nodes/-/services") == expected_url |
| 634 | + |
| 635 | + resp = await client.get(f"/v0/projects/{project_id}/nodes/-/services") |
| 636 | + data, _ = await assert_status(resp, status.HTTP_200_OK) |
| 637 | + |
| 638 | + assert data == { |
| 639 | + "projectUuid": project_id, |
| 640 | + "services": [], |
| 641 | + "missing": None, |
| 642 | + } |
0 commit comments