Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
3f37302
WIP: implement well core information feature tests
jacob-a-brown Nov 4, 2025
deee08a
WIP: add well purposes to feature testing data
jacob-a-brown Nov 4, 2025
7fdf2df
WIP: well core information behave test development
jacob-a-brown Nov 4, 2025
54abcab
WIP: id link testing
jacob-a-brown Nov 4, 2025
819f7ce
WIP: well core information behave test
jacob-a-brown Nov 4, 2025
8dd71e3
Merge branch 'bdms-221' into bdms-221-jab-bdms-223
jacob-a-brown Nov 4, 2025
b777dc5
WIP: erase and rebuild db each time
jacob-a-brown Nov 4, 2025
fe10338
Merge branch 'bdms-221' into bdms-221-jab-bdms-223
jacob-a-brown Nov 4, 2025
1486fd9
feat: note reused statements and places for fixtures
jacob-a-brown Nov 4, 2025
c2df7af
WIP: note taking for well core information
jacob-a-brown Nov 4, 2025
e8c9442
refactor: address PR comments
jacob-a-brown Nov 5, 2025
6ee0719
refactor: update behave tests per PR feedback
jacob-a-brown Nov 5, 2025
5e3a106
refactor: update feature tests per PR feedback
jacob-a-brown Nov 5, 2025
62fed51
Merge branch 'staging' into bdms-221-jab-bdms-223
jacob-a-brown Nov 6, 2025
c504b27
refactor: revert to context.response for the single request
jacob-a-brown Nov 6, 2025
217c9fe
Merge branch 'staging' into bdms-221-jab-bdms-223
jacob-a-brown Nov 6, 2025
995d6b1
refactor: use context objects to get well id for get request
jacob-a-brown Nov 6, 2025
87dba2b
feat: update tests
jacob-a-brown Nov 6, 2025
077dacd
feat: add id links to pseudo fixtures
jacob-a-brown Nov 6, 2025
2ce6f5c
refactor: update groups in testing data
jacob-a-brown Nov 7, 2025
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
129 changes: 128 additions & 1 deletion tests/features/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
Parameter,
Deployment,
TransducerObservationBlock,
StatusHistory,
ThingIdLink,
)
from db.engine import session_ctx

Expand Down Expand Up @@ -142,7 +144,9 @@ def add_sensor(context, session, sid):

@add_context_object_container("groups")
def add_group(context, session, wells, gid):
group = Group(name="Collabnet")
group = Group(
name="Collabnet", description="Healy Collaborative Network", project_area=None
)
for w in wells:
assoc = GroupThingAssociation(group=group, thing=w)
session.add(assoc)
Expand Down Expand Up @@ -187,6 +191,54 @@ def add_block(context, session, parameter):
return block


@add_context_object_container("status_histories")
def add_status_history(
context,
session,
status_type,
status_value,
start_date,
end_date,
reason,
statusable_id,
statusable_type,
):
status_history = StatusHistory(
status_type=status_type,
status_value=status_value,
start_date=start_date,
end_date=end_date,
reason=reason,
statusable_id=statusable_id,
statusable_type=statusable_type,
)

session.add(status_history)
session.commit()
session.refresh(status_history)

context.objects["status_histories"].append(status_history)
return status_history


@add_context_object_container("id_links")
def add_id_link(
context, session, thing, relation, alternate_id, alternate_organization
):
id_link = ThingIdLink(
thing_id=thing.id,
relation=relation,
alternate_id=alternate_id,
alternate_organization=alternate_organization,
)
session.add(id_link)
session.commit()
session.refresh(id_link)

context.objects["id_links"].append(id_link)
return id_link


def before_all(context):
context.objects = {}

Expand All @@ -209,6 +261,81 @@ def before_all(context):
sensor_1 = add_sensor(context, session, well_1.id)
deployment = add_deployment(context, session, well_1.id, sensor_1.id)

well_status_1 = add_status_history(
context,
session,
status_type="well_status",
status_value="Active, pumping well",
start_date=datetime(2020, 1, 1),
end_date=datetime(2021, 1, 1),
reason="Initial status",
statusable_id=well_1.id,
statusable_type="Thing",
)

well_status_2 = add_status_history(
context,
session,
status_type="well_status",
status_value="Destroyed, exists but not usable",
start_date=datetime(2021, 1, 1),
end_date=None,
reason="Roving bovine",
statusable_id=well_1.id,
statusable_type="Thing",
)

monitoring_status_1 = add_status_history(
context,
session,
status_type="monitoring_status",
status_value="currently monitored",
start_date=datetime(2020, 1, 1),
end_date=datetime(2021, 1, 1),
reason="Initial monitoring status",
statusable_id=well_1.id,
statusable_type="Thing",
)

monitoring_status_2 = add_status_history(
context,
session,
status_type="monitoring_status",
status_value="not monitored",
start_date=datetime(2021, 1, 1),
end_date=None,
reason="Roving bovine destroyed well",
statusable_id=well_1.id,
statusable_type="Thing",
)

id_link_1 = add_id_link(
context,
session,
thing=well_1,
relation="same_as",
alternate_id="12345678",
alternate_organization="USGS",
)

id_link_2 = add_id_link(
context,
session,
thing=well_1,
relation="same_as",
alternate_id="OSE-0001",
alternate_organization="NMOSE",
)

id_link_3 = add_id_link(
context,
session,
thing=well_1,
relation="same_as",
alternate_id="Roving Bovine Ranch Well #1",
alternate_organization="NMBGMR",
)

# parameter ID can be hardcoded because init_parameter always creates the same one
parameter = session.get(Parameter, 1)
add_obs = add_block(context, session, parameter)
Expand Down
Loading
Loading