Skip to content

Commit 119e9ce

Browse files
committed
fix: improved thing tests wrt creating a new thing
1 parent b39adcf commit 119e9ce

4 files changed

Lines changed: 16 additions & 8 deletions

File tree

api/thing.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,6 @@ def create_thing(
221221
"""
222222
Create a new well in the database.
223223
"""
224-
# print("Creating well with data:", well_data, user)
225-
226224
return add_thing(session, thing_data)
227225

228226

db/location.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class Location(Base, AutoBaseMixin, ReleaseMixin):
3636
# visible = Column(Boolean, default=False, nullable=False)
3737
__versioned__ = {}
3838

39+
name = mapped_column(String(255), nullable=True)
3940
notes = mapped_column(Text, nullable=True)
4041
point: Mapped[WKBElement] = mapped_column(
4142
Geometry(geometry_type="POINT", srid=4326, spatial_index=True)

schemas_v2/thing.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,14 @@ class CreateThingIdLink(BaseModel):
3434
alternate_organization: str
3535

3636

37-
class CreateThing(BaseModel):
38-
"""
39-
Schema for creating a thing.
40-
"""
41-
37+
class CreateBaseThing(BaseModel):
4238
location_id: int | None = None # Optional location ID for the thing
4339
name: str # Name of the thing
4440
group: str | None = None # Optional group ID for the thing
4541
thing_type: str | None = None # Type of the thing (e.g., "Well", "Spring", etc.)
4642

4743

48-
class CreateWell(CreateThing):
44+
class CreateWell(CreateBaseThing):
4945
"""
5046
Schema for creating a well.
5147
"""
@@ -58,6 +54,17 @@ class CreateWell(CreateThing):
5854
well_construction_notes: str | None = None
5955

6056

57+
class CreateThing(CreateWell):
58+
"""
59+
Schema for creating a thing.
60+
"""
61+
62+
63+
64+
65+
66+
67+
6168
class CreateWellScreen(BaseModel):
6269
"""
6370
Schema for creating a well screen.

tests/test_thing.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ def test_add_well():
7272
assert response.status_code == 201
7373
data = response.json()
7474
assert "id" in data
75+
assert data["name"] == "Test Well"
76+
assert data['well_type'] == "Monitoring"
7577

7678
response = client.post(
7779
"/thing",

0 commit comments

Comments
 (0)