hub/non_functional_tests/test_schedules_factory.py

61 lines
2.1 KiB
Python
Raw Normal View History

"""
TestSchedulesFactory test and validate the city model structure schedules
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
from pathlib import Path
from unittest import TestCase
from imports.geometry_factory import GeometryFactory
from imports.usage_factory import UsageFactory
from imports.construction_factory import ConstructionFactory
from imports.schedules_factory import SchedulesFactory
from imports.geometry.helpers.geometry_helper import GeometryHelper
class TestSchedulesFactory(TestCase):
"""
TestSchedulesFactory TestCase
"""
def setUp(self) -> None:
"""
Configure test environment
:return:
"""
self._city_gml = None
self._example_path = (Path(__file__).parent / 'tests_data').resolve()
def _get_citygml(self, file):
file_path = (self._example_path / file).resolve()
self._city = GeometryFactory('citygml', file_path).city
ConstructionFactory('nrel', self._city).enrich()
self.assertIsNotNone(self._city, 'city is none')
for building in self._city.buildings:
building.function = GeometryHelper.hft_to_function[building.function]
UsageFactory('hft', self._city).enrich()
return self._city
def test_comnet_archetypes(self):
file = (self._example_path / 'one_building_in_kelowna.gml').resolve()
city = self._get_citygml(file)
occupancy_handler = 'comnet'
SchedulesFactory(occupancy_handler, city).enrich()
for building in city.buildings:
self.assertIsNot(len(building.usage_zones), 0, 'no building usage_zones defined')
for usage_zone in building.usage_zones:
2021-08-25 14:29:30 -04:00
print(usage_zone.schedules)
self.assertTrue(usage_zone.schedules)
2021-08-25 14:29:30 -04:00
def test_doe_idf_archetypes(self):
file = (self._example_path / 'C40_Final.gml').resolve()
city = self._get_citygml(file)
occupancy_handler = 'doe_idf'
SchedulesFactory(occupancy_handler, city).enrich()
2021-08-26 13:27:43 -04:00
for building in city.buildings:
for usage_zone in building.usage_zones:
for schedule in usage_zone.schedules:
print(schedule)
print(usage_zone.schedules[schedule])