""" 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.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 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: self.assertTrue(usage_zone.schedules)