hub/unittests/test_customized_imports_factory.py

52 lines
1.8 KiB
Python

"""
TestCustomizedImportsFactory tests and validates the factory to import customized data
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2021 Project Author Pilar Monsalvete Alvarez de Uribarri pilar.monsalvete@concordia.ca
"""
from pathlib import Path
from unittest import TestCase
import helpers.constants as cte
from imports.geometry_factory import GeometryFactory
from imports.usage_factory import UsageFactory
from imports.customized_imports_factory import CustomizedImportsFactory
from imports.customized_imports.sanam_customized_usage_parameters import SanamCustomizedUsageParameters as scp
class TestCustomizedImportsFactory(TestCase):
"""
TestCustomizedImportsFactory 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
self.assertIsNotNone(_city, 'city is none')
UsageFactory('hft', _city).enrich()
return _city
def test_city_with_customized_data(self):
"""
Enrich the city with the usage information and verify it
:return: None
"""
file = 'one_building_in_kelowna.gml'
city = self._get_citygml(file)
CustomizedImportsFactory(scp, city).enrich()
for building in city.buildings:
self.assertIsNot(len(building.internal_zones), 0, 'no building internal_zones defined')
for internal_zone in building.internal_zones:
for usage_zone in internal_zone.usage_zones:
if usage_zone.usage != cte.RESIDENTIAL:
self.assertIsNotNone(usage_zone.mechanical_air_change, 'mechanical air change rate is none')
self.assertIsNotNone(usage_zone.occupancy.occupancy_density, 'occupancy density us none')