Coverage for bim2sim/plugins/PluginTEASER/test/unit/task/test_weather.py: 0%
31 statements
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-12 17:09 +0000
« prev ^ index » next coverage.py v7.6.12, created at 2025-03-12 17:09 +0000
1import tempfile
2import unittest
3from pathlib import Path
5import bim2sim.tasks.common.create_elements
6from bim2sim.kernel.decision.decisionhandler import DebugDecisionHandler
7from bim2sim.plugins import Plugin
8from bim2sim.project import Project
9from bim2sim.plugins.PluginTEASER.bim2sim_teaser.sim_settings import \
10 TEASERSimSettings
11from bim2sim.utilities.types import IFCDomain
12from bim2sim.tasks.common import Weather
15class PluginWeatherDummyTEASER(Plugin):
16 name = 'TEASER'
17 sim_settings = TEASERSimSettings
18 default_tasks = [
19 bim2sim.tasks.common.load_ifc.LoadIFC,
20 bim2sim.tasks.common.create_elements.CreateElementsOnIfcTypes,
21 Weather
22 ]
25test_rsrc_path = (Path(
26 __file__).parent.parent.parent.parent.parent.parent.parent
27 / 'test/resources')
30class TestWeather(unittest.TestCase):
31 """Tests the weather task for loading weather files for simulations."""
33 def tearDown(self):
34 self.project.finalize(True)
35 self.test_dir.cleanup()
37 def test_weather_modelica(self):
38 """Test if the weather file is correctly set for modelica."""
39 self.test_dir = tempfile.TemporaryDirectory()
40 ifc_paths = {
41 IFCDomain.arch: test_rsrc_path / 'arch/ifc/AC20-FZK-Haus.ifc'}
42 self.project = Project.create(self.test_dir.name, ifc_paths,
43 plugin=PluginWeatherDummyTEASER)
44 self.project.sim_settings.weather_file_path = (
45 test_rsrc_path / 'weather_files/DEU_NW_Aachen.105010_TMYx.mos')
46 handler = DebugDecisionHandler([])
47 handler.handle(self.project.run(cleanup=False))
48 try:
49 weather_file = self.project.playground.state['weather_file']
50 except Exception:
51 raise ValueError(f"No weather file set through Weather task. An"
52 f"error occurred.")
53 self.assertEquals(weather_file,
54 self.project.sim_settings.weather_file_path)