Commit 512e012a authored by Eric Duminil's avatar Eric Duminil
Browse files

More tests

parent ace2fe1b
......@@ -7,9 +7,9 @@ from simstadt.runner import run_workflow_with_citygml
TEST_DATA = Path(__file__).parent / "data"
CITYGML = TEST_DATA / "TestRepo" / "MiniBuchwald.gml"
TEMPLATE1 = TEST_DATA / "Templates" / "01_HeatDemand"
TEMPLATE2 = TEST_DATA / "Templates" / "02_LoadProfile"
TEMPLATE3 = TEST_DATA / "Templates" / "03_PV"
HEAT_TEMPLATE = TEST_DATA / "Templates" / "01_HeatDemand"
LOAD_TEMPLATE = TEST_DATA / "Templates" / "02_LoadProfile"
PV_TEMPLATE = TEST_DATA / "Templates" / "03_PV"
def test_citygml_in_proj_folder(mock_simstadt, tmp_path):
......@@ -19,24 +19,33 @@ def test_citygml_in_proj_folder(mock_simstadt, tmp_path):
gml = proj / CITYGML.name
shutil.copy(CITYGML, gml)
results = run_workflow_with_citygml(TEMPLATE1, gml)
results = run_workflow_with_citygml(HEAT_TEMPLATE, gml)
assert results is not None
assert CITYGML.name in results.citygml
assert results.workflow_path.parent == proj
rich.print(results.kpis)
assert len(results.dataframe) > 0
assert len(results.kpis) == 10
import rich
def test_citygml_with_explicit_project_path(mock_simstadt, tmp_path):
"""CityGML outside .proj with project_path — CityGML is copied to project_path."""
proj = tmp_path / "Test.proj"
proj.mkdir()
results = run_workflow_with_citygml(TEMPLATE2, CITYGML, project_path=proj)
results = run_workflow_with_citygml(LOAD_TEMPLATE, CITYGML, project_path=proj)
assert (proj / CITYGML.name).exists()
assert results is not None
assert results.workflow_path.parent == proj
assert len(results.dataframe) > 0
assert len(results.kpis) == 3
assert results.kpi('Average load').unit == 'kWh / h'
def test_citygml_with_explicit_project_path_no_double_copy(mock_simstadt, tmp_path):
"""CityGML already present in project_path — not copied again."""
......@@ -46,14 +55,18 @@ def test_citygml_with_explicit_project_path_no_double_copy(mock_simstadt, tmp_pa
shutil.copy(CITYGML, dest)
mtime_before = dest.stat().st_mtime
run_workflow_with_citygml(TEMPLATE3, CITYGML, project_path=proj)
results = run_workflow_with_citygml(PV_TEMPLATE, CITYGML, project_path=proj)
assert dest.stat().st_mtime == mtime_before
assert len(results.dataframe) > 0
assert len(results.kpis) == 5
assert results.kpi('Irradiance in module plane').unit == 'W / m²'
def test_citygml_creates_temp_repo(mock_simstadt):
"""CityGML outside .proj with no project_path — temporary repository created."""
results = run_workflow_with_citygml(TEMPLATE1, CITYGML)
results = run_workflow_with_citygml(HEAT_TEMPLATE, CITYGML)
assert results is not None
assert "simstadt_repo" in str(results.workflow_path)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment