Validate solar panel inputs and add tests

This commit is contained in:
blackboxprogramming
2025-08-30 17:56:30 -05:00
parent 844f304db0
commit c618e52219
2 changed files with 28 additions and 2 deletions

View File

@@ -0,0 +1,22 @@
import pathlib
import sys
import pytest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from native_ai_quantum_energy.energy_simulator import solar_panel_output
def test_solar_panel_output_valid():
energy = solar_panel_output(100, 2, 0.5)
assert energy == pytest.approx(100 * 0.5 * 2 * 3600)
def test_solar_panel_output_negative_power():
with pytest.raises(ValueError):
solar_panel_output(-10, 1)
def test_solar_panel_output_negative_hours():
with pytest.raises(ValueError):
solar_panel_output(10, -1)