Skip to content

Commit

Permalink
Revert "tests for bug, should fail"
Browse files Browse the repository at this point in the history
This reverts commit a60bc79.
  • Loading branch information
austinorr committed Feb 1, 2024
1 parent a60bc79 commit b524a7f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 142 deletions.
60 changes: 0 additions & 60 deletions nereid/nereid/tests/test_data/nested_watershed_request.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,73 +1,6 @@
import json

import pytest

from nereid.src.tasks import solve_watershed
from nereid.tests.utils import get_test_data


@pytest.mark.parametrize(
"downstream_facility",
[
{
"facility_type": "biofiltration",
"node_id": "0",
"ref_data_key": "10101000",
"design_storm_depth_inches": 0.85,
"total_volume_cuft": 10000,
"area_sqft": 5000,
"media_filtration_rate_inhr": 5,
},
{
"facility_type": "infiltration",
"node_id": "0",
"ref_data_key": "10101000",
"design_storm_depth_inches": 0.85,
"total_volume_cuft": 4000,
"area_sqft": 2000,
"inf_rate_inhr": 2,
},
{
"facility_type": "bioretention",
"node_id": "0",
"ref_data_key": "10101000",
"design_storm_depth_inches": 0.85,
"total_volume_cuft": 4000,
"retention_volume_cuft": 0.0, # no retention volume
"area_sqft": 1000,
"media_filtration_rate_inhr": 5.25,
"hsg": "b",
},
{
"facility_type": "bioretention",
"node_id": "0",
"ref_data_key": "10101000",
"design_storm_depth_inches": 0.85,
"total_volume_cuft": 4000,
"retention_volume_cuft": 2000,
"area_sqft": 1000,
"media_filtration_rate_inhr": 5.25,
"hsg": "b",
},
],
)
def test_nested_solution(contexts, downstream_facility):
ctx = contexts["default"]
watershed = json.loads(get_test_data("nested_watershed_request.json"))

tmnt_facilities = watershed["treatment_facilities"]
replace_node_id = downstream_facility["node_id"]
for d in tmnt_facilities:
if d["node_id"] == replace_node_id:
d.update(downstream_facility)

res = solve_watershed(
watershed=watershed, treatment_pre_validated=False, context=ctx
)

tmnt_results = [n for n in res["results"] if n.get("node_id") == "0"].pop()
assert tmnt_results["captured_pct"] > 0.0, json.dumps(tmnt_results, indent=2)


TMNT_FACILITIES = [
# (facility, reduces_load, retention, tmnt)
Expand Down
24 changes: 9 additions & 15 deletions nereid/nereid/tests/test_src/test_watershed/test_tasks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
from copy import deepcopy

import networkx as nx
Expand Down Expand Up @@ -49,7 +48,7 @@ def test_solve_watershed_land_surface_only(contexts, watershed_requests, n_nodes


@pytest.mark.parametrize("pct_tmnt", [0.3, 0.6])
@pytest.mark.parametrize("n_nodes", [50, 100, 500])
@pytest.mark.parametrize("n_nodes", [50, 100])
def test_solve_watershed_with_treatment(
contexts, watershed_requests, n_nodes, pct_tmnt
):
Expand All @@ -70,7 +69,7 @@ def test_solve_watershed_with_treatment(
sum_inflow = sum([n.get("runoff_volume_cuft", 0.0) for n in result])
outflow = outfall_results["runoff_volume_cuft_total_discharged"]

assert abs(sum_inflow - sum_ret - outflow) / sum_inflow < 1e-4
assert abs(sum_inflow - sum_ret - outflow) / sum_inflow < 1e-15

scalers = [
("summer_dwTSS_load_lbs_removed", "summer_dwTSS_load_lbs_total_removed"),
Expand Down Expand Up @@ -103,23 +102,18 @@ def test_solve_watershed_with_treatment(
# check that treatment happened
assert outfall_results[load_type] > 0

tmnt_bmps = [
nested_bmps = [
data
for data in response_dict["results"]
if "facility" in data.get("node_type", "")
if (data["eff_area_acres_direct"] < data["eff_area_acres_cumul"])
and "facility" in data.get("node_type", "")
and "simple" not in data.get("node_type", "")
]

for data in tmnt_bmps:
if data["eff_area_acres_direct"] < data["eff_area_acres_cumul"]:
assert (
data["design_volume_cuft_direct"] < data["design_volume_cuft_cumul"]
), data.get("node_type", "")

if (data.get("treatment_volume_cuft", 0) == 0) and (
data.get("treatment_rate_cfs", 0) == 0
):
assert round(data.get("treated_pct"), 3) == 0.0, json.dumps(data, indent=2)
for data in nested_bmps:
assert (
data["design_volume_cuft_direct"] < data["design_volume_cuft_cumul"]
), data.get("node_type", "")


@pytest.mark.parametrize("ctx_key", ["default", "default_no_dw_valid"])
Expand Down

0 comments on commit b524a7f

Please sign in to comment.