From c62ff74c69134cced12bafe4e74e19ca564974ae Mon Sep 17 00:00:00 2001 From: jakeross Date: Mon, 3 Nov 2025 20:02:01 -0700 Subject: [PATCH 1/2] fix: add thing_type parameter to function in thing.py for enhanced query capabilities --- api/thing.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/thing.py b/api/thing.py index b65672880..901eb4ce3 100644 --- a/api/thing.py +++ b/api/thing.py @@ -299,6 +299,7 @@ async def get_things( user: viewer_dependency, session: session_dependency, # thing_id: int = None, + thing_type: str = None, within: str = None, query: str = None, sort: str = None, @@ -319,6 +320,7 @@ async def get_things( session, sort, within=within, + thing_type=thing_type, ) From 16ce4aa6bb3394eb8c1a872e8e1c81bbcf6ed94e Mon Sep 17 00:00:00 2001 From: jakeross Date: Tue, 4 Nov 2025 13:34:41 -0700 Subject: [PATCH 2/2] fix: refactor thing API to improve endpoint structure and initialization logic --- api/thing.py | 2 -- tests/features/steps/api_fixture.py | 9 ++++----- tests/features/steps/{thing-query.py => thing-path.py} | 4 ++-- 3 files changed, 6 insertions(+), 9 deletions(-) rename tests/features/steps/{thing-query.py => thing-path.py} (89%) diff --git a/api/thing.py b/api/thing.py index 901eb4ce3..b65672880 100644 --- a/api/thing.py +++ b/api/thing.py @@ -299,7 +299,6 @@ async def get_things( user: viewer_dependency, session: session_dependency, # thing_id: int = None, - thing_type: str = None, within: str = None, query: str = None, sort: str = None, @@ -320,7 +319,6 @@ async def get_things( session, sort, within=within, - thing_type=thing_type, ) diff --git a/tests/features/steps/api_fixture.py b/tests/features/steps/api_fixture.py index c5f875531..56581fcfd 100644 --- a/tests/features/steps/api_fixture.py +++ b/tests/features/steps/api_fixture.py @@ -37,18 +37,17 @@ Thing, LocationThingAssociation, Sensor, - LexiconTerm, Group, GroupThingAssociation, ) from db.engine import session_ctx with session_ctx() as session: - if session.query(LexiconTerm).count() == 0: - erase_and_rebuild_db(session) + # if session.query(LexiconTerm).count() == 0: + erase_and_rebuild_db(session) - init_lexicon() - init_parameter() + init_lexicon() + init_parameter() def add_location(lid): diff --git a/tests/features/steps/thing-query.py b/tests/features/steps/thing-path.py similarity index 89% rename from tests/features/steps/thing-query.py rename to tests/features/steps/thing-path.py index 47a61d896..0452ad908 100644 --- a/tests/features/steps/thing-query.py +++ b/tests/features/steps/thing-path.py @@ -19,7 +19,7 @@ @when('the user requests things with type "water well"') def step_impl(context): - context.response = context.client.get("/thing", params={"thing_type": "water well"}) + context.response = context.client.get("/thing/water-well") @then("the response should include at least one thing") @@ -37,7 +37,7 @@ def step_impl(context): @when('the user requests things with type "spring"') def step_impl(context): - context.response = context.client.get("/thing", params={"thing_type": "spring"}) + context.response = context.client.get("/thing/spring") @then('the response should only include things of type "spring"')