diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5098607b3..c25a9c145 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 diff --git a/tests/features/environment.py b/tests/features/environment.py index ada75806e..04850e916 100644 --- a/tests/features/environment.py +++ b/tests/features/environment.py @@ -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) @@ -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) diff --git a/tests/features/steps/geojson-response.py b/tests/features/steps/geojson-response.py index 81e6a72eb..4244ec4e4 100644 --- a/tests/features/steps/geojson-response.py +++ b/tests/features/steps/geojson-response.py @@ -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 ============================================= diff --git a/tests/features/steps/location-notes.py b/tests/features/steps/location-notes.py index c27f37fc6..d8c993b45 100644 --- a/tests/features/steps/location-notes.py +++ b/tests/features/steps/location-notes.py @@ -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") @@ -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 =============================================