city_retrofit/unittests/test_schedules_factory.py

70 lines
2.5 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._example_path = (Path(__file__).parent / 'tests_data').resolve()
def _get_citygml(self, file):
file_path = (self._example_path / file).resolve()
2021-08-27 12:51:30 -04:00
_city = GeometryFactory('citygml', file_path).city
ConstructionFactory('nrel', _city).enrich()
self.assertIsNotNone(_city, 'city is none')
for building in _city.buildings:
building.function = GeometryHelper.hft_to_function[building.function]
2021-08-27 12:51:30 -04:00
UsageFactory('hft', _city).enrich()
return _city
def test_comnet_archetypes(self):
2021-08-27 12:51:30 -04:00
"""
Enrich the city with commet schedule archetypes and verify it
"""
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:
self.assertIsNot(len(usage_zone.schedules), 0, 'no usage_zones schedules defined')
for schedule in usage_zone.schedules:
self.assertIsNotNone(schedule.type)
self.assertIsNotNone(schedule.values)
self.assertIsNotNone(schedule.data_type)
self.assertIsNotNone(schedule.time_step)
self.assertIsNotNone(schedule.time_range)
self.assertIsNotNone(schedule.day_types)
2021-08-25 14:29:30 -04:00
def test_doe_idf_archetypes(self):
2021-08-27 12:51:30 -04:00
"""
Enrich the city with doe_idf schedule archetypes and verify it
"""
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)