city_retrofit/tests/test_idf.py

62 lines
2.3 KiB
Python

"""
TestOccupancyFactory test and validate the city model structure occupancy parameters
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
from pathlib import Path
from unittest import TestCase
from factories.geometry_factory import GeometryFactory
from factories.physics_factory import PhysicsFactory
from factories.usage_factory import UsageFactory
from helpers.idf_helper import IdfHelper
class TestIdf(TestCase):
"""
Test IDF Class
"""
def setUp(self) -> None:
"""
Test setup
:return: None
"""
self._city_gml = None
self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve()
self._output_path = (Path(__file__).parent / 'ep_outputs').resolve()
def _get_city(self):
if self._city_gml is None:
file_path = (self._example_path / 'buildings.gml').resolve()
self._city_gml = GeometryFactory('citygml', file_path).city
PhysicsFactory('us_new_york', self._city_gml, base_path=self._example_path)
UsageFactory('us_new_york', self._city_gml)
return self._city_gml
def test_idf_blocks(self):
idd_file_path = (self._example_path / 'energy+.idd').resolve()
idf_file_path = (self._example_path / 'minimal.idf').resolve()
epw_file_path = (self._example_path / 'montreal.epw').resolve()
_idf = IdfHelper(idf_file_path, idd_file_path, epw_file_path)
city = self._get_city()
for building in city.buildings:
_idf.add_block(building)
break
_idf.run(output_prefix='test_idf_blocks', output_directory="ep_outputs", keep_file=self._output_path)
_idf.read_eso(str(self._example_path))
self.assertEqual(1, 2, "arent equal")
# todo: clean up the files
def test_idf_surfaces(self):
idd_file_path = (self._example_path / 'energy+.idd').resolve()
idf_file_path = (self._example_path / 'minimal.idf').resolve()
epw_file_path = (self._example_path / 'montreal.epw').resolve()
_idf = IdfHelper(idf_file_path, idd_file_path, epw_file_path)
city = self._get_city()
for building in city.buildings:
_idf.add_surfaces(building)
_idf.run(output_prefix='test_idf_surfaces', output_directory="ep_outputs", keep_file=self._output_path)
self.assertEqual(1, 2, "arent equal")
# todo: clean up the files