""" TestSchedulesFactory test and validate the city model structure schedules SPDX - License - Identifier: LGPL - 3.0 - or -later Copyright © 2022 Concordia CERC group Project Coder 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() _city = GeometryFactory('citygml', file_path).city for building in _city.buildings: building.year_of_construction = 2006 ConstructionFactory('nrel', _city).enrich() self.assertIsNotNone(_city, 'city is none') for building in _city.buildings: building.function = GeometryHelper.libs_function_from_hft(building.function) building.year_of_construction = 2005 UsageFactory('hft', _city).enrich() return _city def test_doe_idf_archetypes(self): """ 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() for building in city.buildings: for internal_zone in building.internal_zones: self.assertTrue(len(internal_zone.usage_zones) > 0) for usage_zone in internal_zone.usage_zones: self.assertIsNot(len(usage_zone.occupancy.occupancy_schedules), 0, 'no occupancy schedules defined') for schedule in usage_zone.occupancy.occupancy_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) self.assertIsNot(len(usage_zone.lighting.schedules), 0, 'no lighting schedules defined') for schedule in usage_zone.lighting.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)