Skip to content

Commit ee93a3f

Browse files
committed
fix: change tests to use spring/water well fixtures
1 parent d46710d commit ee93a3f

8 files changed

Lines changed: 20 additions & 18 deletions

File tree

api/thing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ def database_error_handler(
8282
"""
8383

8484
error_message = error.orig.args[0]["M"]
85-
print(error_message)
8685

8786
if (
8887
error_message

tests/test_asset.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ def test_upload_asset():
8686
assert "storage_path" in data
8787

8888

89-
def test_add_asset(thing):
89+
def test_add_asset(water_well_thing):
9090
payload = {
91-
"thing_id": thing.id,
91+
"thing_id": water_well_thing.id,
9292
"name": "test_asset.png",
9393
"label": "Test Asset",
9494
"uri": "https://storage.googleapis.com/mock-bucket/mock-asset",
@@ -114,7 +114,7 @@ def test_add_asset(thing):
114114
cleanup_post_test(Asset, data["id"])
115115

116116

117-
def test_add_asset_409_bad_thing_id(thing):
117+
def test_add_asset_409_bad_thing_id(water_well_thing):
118118
bad_thing_id = 99999
119119
payload = {
120120
"thing_id": bad_thing_id,
@@ -160,9 +160,9 @@ def test_get_assets(asset, asset_with_associated_thing):
160160
assert data["items"][1]["signed_url"] == None
161161

162162

163-
def test_get_assets_thing_id(asset_with_associated_thing, thing):
163+
def test_get_assets_thing_id(asset_with_associated_thing, water_well_thing):
164164
with patch("api.asset.get_storage_bucket", return_value=MockStorageBucket()):
165-
query_parameters = {"thing_id": thing.id}
165+
query_parameters = {"thing_id": water_well_thing.id}
166166
response = client.get("/asset", params=query_parameters)
167167
assert response.status_code == 200
168168
data = response.json()

tests/test_contact.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,11 @@ def test_validate_email():
5959
# ADD tests ====================================================================
6060

6161

62-
def test_add_contact(thing):
62+
def test_add_contact(spring_thing):
6363
payload = {
6464
"name": "Test Contact 2",
6565
"role": "Owner",
66-
"thing_id": thing.id,
66+
"thing_id": spring_thing.id,
6767
"emails": [{"email": "testcontact2@gmail.com", "email_type": "Primary"}],
6868
"phones": [{"phone_number": "+14153334444", "phone_type": "Primary"}],
6969
"addresses": [

tests/test_geospatial.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ def populate():
102102
session.delete(loc1)
103103
session.delete(loc2)
104104
session.delete(group)
105+
session.delete(thing1)
106+
session.delete(thing2)
105107
session.commit()
106108

107109

@@ -112,7 +114,6 @@ def test_get_project_area():
112114
assert "type" in data
113115
assert data["type"] == "FeatureCollection"
114116
assert "features" in data
115-
print(data)
116117
assert len(data["features"]) > 0
117118
assert data["features"][0]["properties"]["group_id"] == 1
118119
assert data["features"][0]["properties"]["group_name"] == "Test Group Foo"

tests/test_observation.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,10 +429,13 @@ def test_get_groundwater_observation_by_sample(sample):
429429
assert len(items) > 0, "Expected at least one groundwater observation for the thing"
430430

431431

432-
def test_get_groundwater_observation_by_thing(thing):
432+
def test_get_groundwater_observation_by_thing(water_well_thing):
433433
response = client.get(
434434
"/observation/groundwater-level",
435-
params={"thing_id": thing.id, "observed_property": "groundwater level"},
435+
params={
436+
"thing_id": water_well_thing.id,
437+
"observed_property": "groundwater level",
438+
},
436439
)
437440
assert response.status_code == 200
438441
data = response.json()

tests/test_sample.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,12 @@ def test_validate_sample_top_and_bottom():
5353

5454

5555
# ============= Post tests for samples =============================================
56-
def test_add_sample(thing, sensor):
56+
def test_add_sample(spring_thing, sensor):
5757
"""
5858
Test adding a sample.
5959
"""
6060
payload = {
61-
"thing_id": thing.id,
61+
"thing_id": spring_thing.id,
6262
"sample_type": "groundwater",
6363
"field_sample_id": "FS-1234567",
6464
"sample_date": "2025-01-01T00:00:00Z",
@@ -96,12 +96,12 @@ def test_add_sample(thing, sensor):
9696
cleanup_post_test(Sample, data["id"])
9797

9898

99-
def test_409_add_sample_invalid_field_sample_id(sample, thing):
99+
def test_409_add_sample_invalid_field_sample_id(sample, spring_thing):
100100
"""
101101
Test adding a sample with an invalid field_sample_id.
102102
"""
103103
payload = {
104-
"thing_id": thing.id,
104+
"thing_id": spring_thing.id,
105105
"sample_type": "groundwater",
106106
"field_sample_id": sample.field_sample_id, # This should already exist
107107
"sample_date": "2025-01-01T00:00:00Z",

tests/test_search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@
2222
from tests import client
2323

2424

25-
def test_search_api(thing, contact, email, phone, address):
25+
def test_search_api(water_well_thing, spring_thing, contact):
2626
response = client.get("/search", params={"q": "Test"})
2727
assert response.status_code == 200
2828
data = response.json()
2929
assert isinstance(data, dict)
3030
items = data.get("items")
3131
assert isinstance(items, list)
32-
assert len(items) == 2
32+
assert len(items) == 3
3333

3434

3535
@pytest.mark.skip(reason="This test is not working .")

tests/test_thing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,6 @@ def test_get_things(water_well_thing, spring_thing):
540540
response = client.get("/thing")
541541
assert response.status_code == 200
542542
data = response.json()
543-
print(data)
544543
assert data["total"] == 2
545544

546545
assert data["items"][0]["id"] == water_well_thing.id

0 commit comments

Comments
 (0)