Skip to content

Commit 7b264a3

Browse files
committed
parametrize tests
1 parent b618d62 commit 7b264a3

File tree

2 files changed

+40
-38
lines changed

2 files changed

+40
-38
lines changed

soil_id/tests/global/test_global.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,23 @@
2828
]
2929

3030
@pytest.mark.skip
31-
def test_soil_location():
31+
@pytest.mark.parametrize("location", test_locations)
32+
def test_soil_location(location):
3233
with get_datastore_connection() as connection:
33-
for item in test_locations:
34-
logging.info(f"Testing {item['lon']}, {item['lat']}")
35-
start_time = time.perf_counter()
36-
list_soils_result = list_soils_global(connection, item["lon"], item["lat"])
37-
logging.info(f"...time: {(time.perf_counter()-start_time):.2f}s")
38-
rank_soils_result = rank_soils_global(
39-
connection,
40-
item["lon"],
41-
item["lat"],
42-
list_output_data=list_soils_result,
43-
soilHorizon=["Loam"],
44-
horizonDepth=[15],
45-
rfvDepth=[20],
46-
lab_Color=[[41.23035939, 3.623018224, 13.27654356]],
47-
bedrock=None,
48-
cracks=None,
49-
)
50-
sg_soils_result = sg_list(item["lon"], item["lat"])
34+
logging.info(f"Testing {location['lon']}, {location['lat']}")
35+
start_time = time.perf_counter()
36+
list_soils_result = list_soils_global(connection, location["lon"], location["lat"])
37+
logging.info(f"...time: {(time.perf_counter()-start_time):.2f}s")
38+
rank_soils_global(
39+
connection,
40+
location["lon"],
41+
location["lat"],
42+
list_output_data=list_soils_result,
43+
soilHorizon=["Loam"],
44+
horizonDepth=[15],
45+
rfvDepth=[20],
46+
lab_Color=[[41.23035939, 3.623018224, 13.27654356]],
47+
bedrock=None,
48+
cracks=None,
49+
)
50+
sg_list(location["lon"], location["lat"])

soil_id/tests/us/test_us.py

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import logging
1717
import time
1818

19+
import pytest
20+
1921
from soil_id.us_soil import list_soils, rank_soils
2022

2123
test_locations = [
@@ -39,7 +41,8 @@
3941
]
4042

4143

42-
def test_soil_location():
44+
@pytest.mark.parametrize("location", test_locations)
45+
def test_soil_location(location):
4346
# Dummy Soil Profile Data (replicating the structure provided)
4447
soilHorizon = ["LOAM"] * 7
4548
horizonDepth = [1, 10, 20, 50, 70, 100, 120]
@@ -50,24 +53,23 @@ def test_soil_location():
5053
pElev = None
5154
cracks = False
5255

53-
for item in test_locations:
54-
logging.info(f"Testing {item['lon']}, {item['lat']}")
55-
start_time = time.perf_counter()
56-
list_soils_result = list_soils(item["lon"], item["lat"])
57-
logging.info(f"...time: {(time.perf_counter() - start_time):.2f}s")
58-
rank_soils(
59-
item["lon"],
60-
item["lat"],
61-
list_soils_result,
62-
soilHorizon,
63-
horizonDepth,
64-
rfvDepth,
65-
lab_Color,
66-
pSlope,
67-
pElev,
68-
bedrock,
69-
cracks,
70-
)
56+
logging.info(f"Testing {location['lon']}, {location['lat']}")
57+
start_time = time.perf_counter()
58+
list_soils_result = list_soils(location["lon"], location["lat"])
59+
logging.info(f"...time: {(time.perf_counter() - start_time):.2f}s")
60+
rank_soils(
61+
location["lon"],
62+
location["lat"],
63+
list_soils_result,
64+
soilHorizon,
65+
horizonDepth,
66+
rfvDepth,
67+
lab_Color,
68+
pSlope,
69+
pElev,
70+
bedrock,
71+
cracks,
72+
)
7173

7274

7375
def test_empty_rank():

0 commit comments

Comments
 (0)