Skip to content

Commit 4cebedb

Browse files
committed
fix: implemented well-notes tests
1 parent 1310375 commit 4cebedb

1 file changed

Lines changed: 65 additions & 16 deletions

File tree

tests/features/steps/well-notes.py

Lines changed: 65 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,41 +16,90 @@
1616
from behave import when, then
1717

1818

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

2324

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

2829

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

3335

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

3943

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

4453

45-
@then("the response should include well_construction_notes")
54+
@then(
55+
"the response should include location notes (i.e. driving directions and geographic well location notes)"
56+
)
4657
def step_impl(context):
47-
assert "well_construction_notes" in context.response.json()
48-
context.notes = context.response.json()["well_construction_notes"]
58+
data = context.response.json()
59+
location = data["current_location"]
60+
assert "notes" in location, "Response does not include location notes"
61+
assert location["notes"] is not None, "Location notes is null"
62+
context.notes["location"] = location["notes"]
4963

5064

51-
@then("the notes should be a non-empty string")
65+
@then(
66+
"the response should include construction notes (i.e. pump notes and other construction notes)"
67+
)
68+
def step_impl(context):
69+
data = context.response.json()
70+
assert (
71+
"well_construction_notes" in data
72+
), "Response does not include construction notes"
73+
assert data["well_construction_notes"] is not None, "Construction notes is null"
74+
context.notes["construction"] = data["well_construction_notes"]
75+
76+
77+
@then("the response should include general well notes (catch all notes field)")
78+
def step_impl(context):
79+
data = context.response.json()
80+
assert "notes" in data, "Response does not include notes"
81+
assert data["notes"] is not None, "Notes is null"
82+
context.notes["general"] = data["notes"]
83+
84+
85+
@then(
86+
"the response should include measuring notes (notes about measuring/visiting the well, on Access form)"
87+
)
88+
def step_impl(context):
89+
data = context.response.json()
90+
assert "measuring_notes" in data, "Response does not include measuring notes"
91+
assert data["measuring_notes"] is not None, "Measuring notes is null"
92+
context.notes["measuring"] = data["measuring_notes"]
93+
94+
95+
@then(
96+
"the response should include water notes (i.e. water bearing zone information and other info from ose reports)"
97+
)
5298
def step_impl(context):
53-
assert bool(context.notes) == True
99+
data = context.response.json()
100+
assert "water_notes" in data, "Response does not include water notes"
101+
assert data["water_notes"] is not None, "Water notes is null"
102+
context.notes["water"] = data["water_notes"]
54103

55104

56105
# ============= EOF =============================================

0 commit comments

Comments
 (0)