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
10 changes: 7 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ jobs:
DB_DRIVER: postgres
BASE_URL: http://localhost:8000
run: |
uv run behave tests/features/transducer-data-response.feature \
tests/features/thing-type-path-parameters.feature \
tests/features/thing-query-parameters.feature
uv run behave tests/features --tags="@backend and @production" --no-capture
# uv run behave tests/features/transducer-data-response.feature \
# tests/features/thing-type-path-parameters.feature \
# tests/features/thing-query-parameters.feature \
# tests/features/well-notes.feature \
# tests/features/location-notes.feature \
# tests/features/geojson-response.feature
# use this when we have consensus on tag nomenclature
# uv run behave tests/features --tags="@backend and @production" --no-capture

Expand Down
3 changes: 2 additions & 1 deletion tests/features/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def add_sensor(context, session, sid):


@add_context_object_container("groups")
def add_group(context, session, wells, gid):
def add_group(context, session, wells):
group = Group(name="Collabnet")
for w in wells:
assoc = GroupThingAssociation(group=group, thing=w)
Expand Down Expand Up @@ -236,6 +236,7 @@ def before_all(context):
spring_4 = add_spring(context, session, loc_4, name_num=4)
sensor_1 = add_sensor(context, session, well_1.id)
deployment = add_deployment(context, session, well_1.id, sensor_1.id)
add_group(context, session, [well_1, well_2])

# parameter ID can be hardcoded because init_parameter always creates the same one
parameter = session.get(Parameter, 1)
Expand Down
4 changes: 3 additions & 1 deletion tests/features/steps/geojson-response.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ def step_impl(context):
def step_impl(context):
obj = context.response.json()
features = obj["features"]
assert len(features) == 2
assert (
len(features) == 2
), f"Unexpected number of features {len(features)}, features={features}"


# ============= EOF =============================================
33 changes: 26 additions & 7 deletions tests/features/steps/location-notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@
from behave import when, then


@when("the user retrieves the location with ID 1")
@when("the user retrieves the location by ID via path parameter")
def step_impl(context):
context.response = context.client.get("location/1")
location_id = context.objects["locations"][0].id
context.response = context.client.get(f"location/{location_id}")


@then("the response should include a current location")
Expand All @@ -32,11 +33,29 @@ def step_impl(context):
assert context.notes


# @then("the location should include notes")
# def step_impl(context):
# print(context.response.json())
# context.notes = context.response.json()["current_location"]["notes"]
# assert context.notes
@then("the notes should be a list of dictionaries")
def step_impl(context):
assert isinstance(context.notes, list)
assert all(isinstance(n, dict) for n in context.notes)


@then('each note dictionary should have "content" and "note_type" keys')
def step_impl(context):
for note in context.notes:
assert "content" in note
assert "note_type" in note


@then("each note in the notes list should be a non-empty string")
def step_impl(context):
for note in context.notes:
assert note["content"], "Note is empty"


@then("the location response should include notes")
def step_impl(context):
context.notes = context.response.json()["notes"]
assert context.notes


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