Skip to content

Commit ee7c587

Browse files
committed
fixes tests
1 parent 2c8ad35 commit ee7c587

File tree

2 files changed

+29
-69
lines changed

2 files changed

+29
-69
lines changed

services/catalog/src/simcore_service_catalog/service/catalog_services.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ async def list_latest_catalog_services(
194194
filters=filters,
195195
limit=limit,
196196
offset=offset,
197-
access_rights=access_rights,
198197
),
199198
tip="This might be due to malfunction of the background-task or that this call was done while the sync was taking place",
200199
)

services/catalog/tests/unit/with_dbs/test_api_rpc.py

Lines changed: 29 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
from models_library.products import ProductName
1515
from models_library.rest_pagination import MAXIMUM_NUMBER_OF_ITEMS_PER_PAGE
1616
from models_library.services_history import ServiceRelease
17-
from models_library.services_regex import (
18-
DYNAMIC_SERVICE_KEY_PREFIX,
19-
)
2017
from models_library.services_types import ServiceKey, ServiceVersion
2118
from models_library.users import UserID
2219
from packaging import version
@@ -131,6 +128,35 @@ async def test_rpc_list_services_paginated_with_no_services_returns_empty_page(
131128
assert page.meta.total == 0
132129

133130

131+
async def test_rpc_list_services_paginated_with_filters(
132+
background_sync_task_mocked: None,
133+
mocked_director_rest_api: MockRouter,
134+
rpc_client: RabbitMQRPCClient,
135+
product_name: ProductName,
136+
user_id: UserID,
137+
app: FastAPI,
138+
):
139+
assert app
140+
141+
# only computational services introduced by the background_sync_task_mocked
142+
page = await list_services_paginated(
143+
rpc_client,
144+
product_name=product_name,
145+
user_id=user_id,
146+
filters={"service_type": "computational"},
147+
)
148+
assert page.meta.total == page.meta.count
149+
assert page.meta.total > 0
150+
151+
page = await list_services_paginated(
152+
rpc_client,
153+
product_name=product_name,
154+
user_id=user_id,
155+
filters={"service_type": "dynamic"},
156+
)
157+
assert page.meta.total == 0
158+
159+
134160
async def test_rpc_catalog_client(
135161
background_sync_task_mocked: None,
136162
mocked_director_rest_api: MockRouter,
@@ -556,68 +582,3 @@ async def test_rpc_list_my_service_history_paginated(
556582
assert len(release_history) == 2
557583
assert release_history[0].version == service_version_2, "expected newest first"
558584
assert release_history[1].version == service_version_1
559-
560-
561-
async def test_rpc_list_services_paginated_with_filters(
562-
background_sync_task_mocked: None,
563-
mocked_director_rest_api: MockRouter,
564-
rpc_client: RabbitMQRPCClient,
565-
product_name: ProductName,
566-
user_id: UserID,
567-
app: FastAPI,
568-
create_fake_service_data: Callable,
569-
services_db_tables_injector: Callable,
570-
):
571-
assert app
572-
573-
# only computational services introduced by the background_sync_task_mocked
574-
page = await list_services_paginated(
575-
rpc_client,
576-
product_name=product_name,
577-
user_id=user_id,
578-
filters={"service_type": "computational"},
579-
)
580-
assert page.meta.total == page.meta.count
581-
assert page.meta.total > 0
582-
583-
page = await list_services_paginated(
584-
rpc_client,
585-
product_name=product_name,
586-
user_id=user_id,
587-
filters={"service_type": "dynamic"},
588-
)
589-
assert page.meta.total == 0
590-
591-
# Create fake services with different types
592-
service_key_1 = f"{DYNAMIC_SERVICE_KEY_PREFIX}/test-filter-service"
593-
service_version = "1.2.3"
594-
595-
fake_services = [
596-
create_fake_service_data(
597-
service_key_1,
598-
service_version,
599-
team_access=None,
600-
everyone_access=None,
601-
product=product_name,
602-
),
603-
]
604-
605-
# Inject fake services into the database
606-
await services_db_tables_injector(fake_services)
607-
608-
# Apply a filter to match only computational services
609-
page = await list_services_paginated(
610-
rpc_client,
611-
product_name=product_name,
612-
user_id=user_id,
613-
filters={"service_type": "dynamic"},
614-
)
615-
616-
# Validate the response
617-
assert page.meta.total == 1
618-
assert page.meta.count == 1
619-
assert len(page.data) == 1
620-
assert page.data[0].key == service_key_1
621-
assert page.data[0].service_type == "frontend"
622-
assert page.links.next is None
623-
assert page.links.prev is None

0 commit comments

Comments
 (0)