Coverage for bim2sim/plugins/PluginEnergyPlus/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

1import tempfile 

2import unittest 

3from pathlib import Path 

4 

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.PluginEnergyPlus.bim2sim_energyplus.sim_settings import \ 

10 EnergyPlusSimSettings 

11from bim2sim.utilities.types import IFCDomain 

12from bim2sim.tasks.common import Weather 

13 

14 

15class PluginWeatherDummyEP(Plugin): 

16 name = 'EnergyPlus' 

17 sim_settings = EnergyPlusSimSettings 

18 default_tasks = [ 

19 bim2sim.tasks.common.load_ifc.LoadIFC, 

20 bim2sim.tasks.common.create_elements.CreateElementsOnIfcTypes, 

21 Weather 

22 ] 

23 

24 

25test_rsrc_path = (Path( 

26 __file__).parent.parent.parent.parent.parent.parent.parent 

27 / 'test/resources') 

28 

29 

30class TestWeather(unittest.TestCase): 

31 """Tests the weather task for loading weather files for simulations.""" 

32 

33 def tearDown(self): 

34 self.project.finalize(True) 

35 self.test_dir.cleanup() 

36 

37 def test_weather_energyplus(self): 

38 """Test if the weather file is correctly set for energyplus.""" 

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=PluginWeatherDummyEP) 

44 self.project.sim_settings.weather_file_path = ( 

45 test_rsrc_path / 'weather_files/DEU_NW_Aachen.105010_TMYx.epw') 

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)