Filament/vendor find by ext id + integration tests

This commit is contained in:
Donkie
2024-05-12 19:57:24 +02:00
parent 4af975d390
commit e4d2ecf0dc
9 changed files with 96 additions and 3 deletions

View File

@@ -207,6 +207,15 @@ async def find(
),
example=20.0,
),
external_id: Optional[str] = Query(
default=None,
description=(
"Find filaments imported by the given external ID. "
"Separate multiple IDs with a comma. "
"Specify empty string to match filaments with no external ID."
),
example="polymaker_pla_polysonicblack_1000_175",
),
sort: Optional[str] = Query(
default=None,
title="Sort",
@@ -259,6 +268,7 @@ async def find(
name=name,
material=material,
article_number=article_number,
external_id=external_id,
sort_by=sort_by,
limit=limit,
offset=offset,

View File

@@ -76,6 +76,15 @@ async def find(
title="Vendor Name",
description="Partial case-insensitive search term for the vendor name. Separate multiple terms with a comma.",
),
external_id: Optional[str] = Query(
default=None,
title="Vendor External ID",
description=(
"Exact match for the vendor external ID. "
"Separate multiple IDs with a comma. "
"Specify empty string to match filaments with no external ID."
),
),
sort: Optional[str] = Query(
default=None,
title="Sort",
@@ -104,6 +113,7 @@ async def find(
db_items, total_count = await vendor.find(
db=db,
name=name,
external_id=external_id,
sort_by=sort_by,
limit=limit,
offset=offset,

View File

@@ -98,6 +98,7 @@ async def find(
name: Optional[str] = None,
material: Optional[str] = None,
article_number: Optional[str] = None,
external_id: Optional[str] = None,
sort_by: Optional[dict[str, SortOrder]] = None,
limit: Optional[int] = None,
offset: int = 0,
@@ -121,6 +122,7 @@ async def find(
stmt = add_where_clause_str_opt(stmt, models.Filament.name, name)
stmt = add_where_clause_str_opt(stmt, models.Filament.material, material)
stmt = add_where_clause_str_opt(stmt, models.Filament.article_number, article_number)
stmt = add_where_clause_str_opt(stmt, models.Filament.external_id, external_id)
total_count = None

View File

@@ -9,7 +9,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
from spoolman.api.v1.models import EventType, Vendor, VendorEvent
from spoolman.database import models
from spoolman.database.utils import SortOrder, add_where_clause_str
from spoolman.database.utils import SortOrder, add_where_clause_str, add_where_clause_str_opt
from spoolman.exceptions import ItemNotFoundError
from spoolman.ws import websocket_manager
@@ -50,6 +50,7 @@ async def find(
*,
db: AsyncSession,
name: Optional[str] = None,
external_id: Optional[str] = None,
sort_by: Optional[dict[str, SortOrder]] = None,
limit: Optional[int] = None,
offset: int = 0,
@@ -61,6 +62,7 @@ async def find(
stmt = select(models.Vendor)
stmt = add_where_clause_str(stmt, models.Vendor.name, name)
stmt = add_where_clause_str_opt(stmt, models.Vendor.external_id, external_id)
total_count = None