Skip to content
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
3 changes: 3 additions & 0 deletions db/thing.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ class Thing(Base, AutoBaseMixin, ReleaseMixin, StatusHistoryMixin, PermissionMix
nullable=True,
comment="To audit where the data came from in NM_Aquifer if it was transferred over",
)
notes = mapped_column(Text, nullable=True)
measuring_notes = mapped_column(Text, nullable=True)
water_notes = mapped_column(Text, nullable=True)

# TODO: should `name` be unique?
name: Mapped[str] = mapped_column(
Expand Down
4 changes: 4 additions & 0 deletions schemas/thing.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ class WellResponse(BaseThingResponse):
well_casing_materials: list[CasingMaterial] = []
well_construction_notes: str | None = None

water_notes: str | None = None
measuring_notes: str | None = None
notes: str | None = None

@field_validator("well_purposes", mode="before")
def populate_well_purposes_with_strings(cls, well_purposes):
if well_purposes is not None:
Expand Down
5 changes: 4 additions & 1 deletion tests/features/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
Deployment,
TransducerObservationBlock,
)

from db.engine import session_ctx


Expand Down Expand Up @@ -78,6 +77,9 @@ def add_well(context, session, location, name_num):
well_construction_notes="Test well construction notes",
well_casing_diameter=5.0,
well_casing_depth=10.0,
notes="These are some test well notes",
measuring_notes="These are some measuring notes",
water_notes="This are some water notes",
)
session.add(well)
session.commit()
Expand Down Expand Up @@ -203,6 +205,7 @@ def add_transducer_observation(context, session, block, deployment_id, value):
def before_all(context):
context.objects = {}
rebuild = False
# rebuild = True
with session_ctx() as session:
if rebuild:
erase_and_rebuild_db(session)
Expand Down
81 changes: 65 additions & 16 deletions tests/features/steps/well-notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,90 @@
from behave import when, then


@when("the user retrieves the well 1")
@when("the user retrieves the well 9999")
def step_impl(context):
context.response = context.client.get("thing/water-well/1")
context.response = context.client.get("thing/water-well/9999")
context.notes = {}


@when("the user retrieves the well 9999")
@then("the response should include an error message indicating the well was not found")
def step_impl(context):
context.response = context.client.get("thing/water-well/9999")
assert {"detail": "Thing with ID 9999 not found."} == context.response.json()


@then("the response should contain a current_location field")
@then("the notes should be a non-empty string")
def step_impl(context):
assert "current_location" in context.response.json()
for k, note in context.notes.items():
assert note, f"{k} Note is empty"


@then("the response should include notes")
@when("the user retrieves the well by ID via path parameter")
def step_impl(context):
assert "notes" in context.response.json()
context.notes = context.response.json()["notes"]
context.response = context.client.get(
f"thing/water-well/{context.objects['wells'][0].id}"
)
context.notes = {}


@then("the response should include an error message indicating the well was not found")
@then(
"null values in the response should be represented as JSON null (not placeholder strings)"
)
def step_impl(context):
assert {"detail": "Thing with ID 9999 not found."} == context.response.json()
data = context.response.json()
for k, v in data.items():
if v == "":
assert v is None, f"Value for key {k} is an empty string but should be null"


@then("the response should include well_construction_notes")
@then(
"the response should include location notes (i.e. driving directions and geographic well location notes)"
)
def step_impl(context):
assert "well_construction_notes" in context.response.json()
context.notes = context.response.json()["well_construction_notes"]
data = context.response.json()
location = data["current_location"]
assert "notes" in location, "Response does not include location notes"
assert location["notes"] is not None, "Location notes is null"
context.notes["location"] = location["notes"]


@then("the notes should be a non-empty string")
@then(
"the response should include construction notes (i.e. pump notes and other construction notes)"
)
def step_impl(context):
data = context.response.json()
assert (
"well_construction_notes" in data
), "Response does not include construction notes"
assert data["well_construction_notes"] is not None, "Construction notes is null"
context.notes["construction"] = data["well_construction_notes"]


@then("the response should include general well notes (catch all notes field)")
def step_impl(context):
data = context.response.json()
assert "notes" in data, "Response does not include notes"
assert data["notes"] is not None, "Notes is null"
context.notes["general"] = data["notes"]
Comment thread
jirhiker marked this conversation as resolved.


@then(
"the response should include measuring notes (notes about measuring/visiting the well, on Access form)"
)
def step_impl(context):
data = context.response.json()
assert "measuring_notes" in data, "Response does not include measuring notes"
assert data["measuring_notes"] is not None, "Measuring notes is null"
context.notes["measuring"] = data["measuring_notes"]
Comment thread
jirhiker marked this conversation as resolved.


@then(
"the response should include water notes (i.e. water bearing zone information and other info from ose reports)"
)
def step_impl(context):
assert bool(context.notes) == True
data = context.response.json()
assert "water_notes" in data, "Response does not include water notes"
assert data["water_notes"] is not None, "Water notes is null"
context.notes["water"] = data["water_notes"]
Comment thread
jirhiker marked this conversation as resolved.


# ============= EOF =============================================
Loading