""" TestUsageFactory test and validate the city model structure usages parameters 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.geometry.helpers.geometry_helper import GeometryHelper class TestUsageFactory(TestCase): """ TestUsageFactory 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') return self._city def test_city_with_usage(self): """ Enrich the city with the usages information and verify it :return: None """ file = 'pluto_building.gml' city = self._get_citygml(file) for building in city.buildings: building.function = GeometryHelper.pluto_to_function[building.function] # case 1: HFT UsageFactory('hft', city).enrich() for building in city.buildings: self.assertIsNotNone(building.usage_zones, 'usage_zones not created') for usage_zone in building.usage_zones: self.assertIsNotNone(usage_zone.usage, 'usages is none') self.assertIsNotNone(usage_zone.internal_gains, 'usages is none') self.assertIsNotNone(usage_zone.cooling_setpoint, 'usages is none') self.assertIsNotNone(usage_zone.heating_setback, 'usages is none') self.assertIsNotNone(usage_zone.heating_setpoint, 'usages is none') self.assertIsNotNone(usage_zone.occupancy_density, 'usages is none') self.assertIsNotNone(usage_zone.hours_day, 'usages is none') self.assertIsNotNone(usage_zone.days_year, 'usages is none') self.assertIsNotNone(usage_zone.dhw_average_volume_pers_day, 'usages is none') self.assertIsNotNone(usage_zone.dhw_preparation_temperature, 'usages is none') self.assertIsNotNone(usage_zone.electrical_app_average_consumption_sqm_year, 'usages is none')