From 88b9c4d66cdaacc21a0d659a0692f74c37dba952 Mon Sep 17 00:00:00 2001 From: Austin Orr Date: Wed, 31 Jan 2024 17:58:00 -0800 Subject: [PATCH] Revert "tests for bug, should fail" This reverts commit a60bc7991de90ca9348f1eef6023933e68eaa27d. --- .../test_data/nested_watershed_request.json | 60 ----------------- .../test_watershed/test_minimal_watershed.py | 67 ------------------- .../test_src/test_watershed/test_tasks.py | 24 +++---- 3 files changed, 9 insertions(+), 142 deletions(-) delete mode 100644 nereid/nereid/tests/test_data/nested_watershed_request.json diff --git a/nereid/nereid/tests/test_data/nested_watershed_request.json b/nereid/nereid/tests/test_data/nested_watershed_request.json deleted file mode 100644 index 1bf87cc2..00000000 --- a/nereid/nereid/tests/test_data/nested_watershed_request.json +++ /dev/null @@ -1,60 +0,0 @@ -{ - "graph": { - "edges": [ - { "source": "1", "target": "0" }, - { "source": "e6nL8", "target": "1" }, - { "source": "mAlB4", "target": "e6nL8" }, - { "source": "w3C56", "target": "e6nL8" }, - { "source": "yTuzF", "target": "w3C56" } - ], - "directed": true, - "multigraph": true - }, - "land_surfaces": [ - { - "node_id": "1", - "surface_key": "10101000-COMM-B-5", - "area_acres": 20, - "imp_area_acres": 10 - }, - { - "node_id": "e6nL8", - "surface_key": "10101000-COMM-B-5", - "area_acres": 15, - "imp_area_acres": 6 - }, - { - "node_id": "mAlB4", - "surface_key": "10101000-COMM-B-5", - "area_acres": 30, - "imp_area_acres": 25 - }, - { - "node_id": "yTuzF", - "surface_key": "10101000-COMM-B-5", - "area_acres": 150, - "imp_area_acres": 80 - } - ], - "treatment_facilities": [ - { - "facility_type": "biofiltration", - "node_id": "0", - "ref_data_key": "10101000", - "design_storm_depth_inches": 0.85, - "total_volume_cuft": 100000, - "area_sqft": 50000, - "media_filtration_rate_inhr": 5 - }, - { - "facility_type": "infiltration", - "node_id": "w3C56", - "ref_data_key": "10101000", - "design_storm_depth_inches": 0.8, - "total_volume_cuft": 100000, - "area_sqft": 25000, - "inf_rate_inhr": 2 - } - ], - "treatment_sites": [] -} diff --git a/nereid/nereid/tests/test_src/test_watershed/test_minimal_watershed.py b/nereid/nereid/tests/test_src/test_watershed/test_minimal_watershed.py index d741a2ae..6eec6a82 100644 --- a/nereid/nereid/tests/test_src/test_watershed/test_minimal_watershed.py +++ b/nereid/nereid/tests/test_src/test_watershed/test_minimal_watershed.py @@ -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) diff --git a/nereid/nereid/tests/test_src/test_watershed/test_tasks.py b/nereid/nereid/tests/test_src/test_watershed/test_tasks.py index 015fd75d..a9cbf4d3 100644 --- a/nereid/nereid/tests/test_src/test_watershed/test_tasks.py +++ b/nereid/nereid/tests/test_src/test_watershed/test_tasks.py @@ -1,4 +1,3 @@ -import json from copy import deepcopy import networkx as nx @@ -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 ): @@ -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"), @@ -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"])