Skip to content

🐛 fix licensed items listing with hidden flag #7232

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,11 @@ async def list_licensed_items(
)

if filter_by_licensed_resource_type:
base_query.where(
base_query = base_query.where(
licensed_items.c.licensed_resource_type == filter_by_licensed_resource_type
)
if not include_hidden_items_on_market:
base_query.where(licensed_items.c.is_hidden_on_market.is_(False))
base_query = base_query.where(licensed_items.c.is_hidden_on_market.is_(False))

# Select total count from base_query
subquery = base_query.subquery()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from simcore_postgres_database.models.licensed_item_to_resource import (
licensed_item_to_resource,
)
from simcore_postgres_database.models.licensed_items import licensed_items
from simcore_postgres_database.utils_repos import transaction_context
from simcore_service_webserver.db.models import UserRole
from simcore_service_webserver.db.plugin import get_asyncpg_engine
Expand Down Expand Up @@ -103,6 +104,21 @@ async def test_licensed_items_listing(
assert "additionalField" not in source
assert "additional_field" not in source

# Testing hidden flag
async with transaction_context(get_asyncpg_engine(client.app)) as conn:
await conn.execute(
licensed_items.update()
.values(
is_hidden_on_market=True,
)
.where(licensed_items.c.licensed_item_id == _licensed_item_id)
)

url = client.app.router["list_licensed_items"].url_for()
resp = await client.get(f"{url}")
data, _ = await assert_status(resp, status.HTTP_200_OK)
assert data == []


_LICENSED_ITEM_PURCHASE_GET = (
rut_licensed_items_purchases.LicensedItemPurchaseGet.model_validate(
Expand Down
Loading