Spaces:
Running
Running
| from mcp_tox_calc.equations import ( | |
| calculate_epa_elcr_csf, | |
| calculate_epa_elcr_iur, | |
| calculate_fda_ctp_elcr, | |
| run_batch_cancer_risk, | |
| ) | |
| def test_calculate_epa_elcr_csf_basic(): | |
| out = calculate_epa_elcr_csf( | |
| { | |
| "route": "oral", | |
| "exposure_value": 0.01, | |
| "exposure_unit": "mg/kg-day", | |
| "body_weight_kg": 70, | |
| "csf_value": 1.5, | |
| "csf_unit": "(mg/kg-day)^-1", | |
| } | |
| ) | |
| assert round(out["result_value"], 8) == 0.015 | |
| def test_calculate_epa_elcr_iur_basic(): | |
| out = calculate_epa_elcr_iur( | |
| { | |
| "route": "inhalation", | |
| "air_conc_value": 100, | |
| "air_conc_unit": "ug/m3", | |
| "iur_value": 1e-6, | |
| "iur_unit": "(ug/m3)^-1", | |
| } | |
| ) | |
| assert round(out["result_value"], 8) == 0.0001 | |
| def test_fda_wrapper_aggregates_components(): | |
| out = calculate_fda_ctp_elcr( | |
| { | |
| "constituents": [ | |
| { | |
| "route": "oral", | |
| "exposure_value": 0.01, | |
| "exposure_unit": "mg/kg-day", | |
| "body_weight_kg": 70, | |
| "csf_value": 1.0, | |
| "csf_unit": "(mg/kg-day)^-1", | |
| }, | |
| { | |
| "route": "inhalation", | |
| "air_conc_value": 50, | |
| "air_conc_unit": "ug/m3", | |
| "iur_value": 1e-6, | |
| "iur_unit": "(ug/m3)^-1", | |
| }, | |
| ] | |
| } | |
| ) | |
| assert out["result_value"] > 0 | |
| assert len(out["component_results"]) == 2 | |
| def test_batch_handles_mixed_rows(): | |
| out = run_batch_cancer_risk( | |
| { | |
| "rows": [ | |
| { | |
| "record_id": "r1", | |
| "chemical_name": "ChemA", | |
| "route": "oral", | |
| "exposure_value": 0.02, | |
| "exposure_unit": "mg/kg-day", | |
| "body_weight_kg": 70, | |
| "csf_value": 1.1, | |
| "csf_unit": "(mg/kg-day)^-1", | |
| }, | |
| { | |
| "record_id": "r2", | |
| "chemical_name": "ChemB", | |
| "route": "oral" | |
| }, | |
| ] | |
| } | |
| ) | |
| assert out["summary"]["total_rows"] == 2 | |
| assert out["summary"]["ok_rows"] == 1 | |
| assert out["summary"]["error_rows"] == 1 | |