hub/tests/test_schedules_factory.py

52 lines
1.8 KiB
Python
Raw Normal View History

2020-10-22 11:02:41 -04:00
"""
2020-12-15 15:15:40 -05:00
TestSchedulesFactory test and validate the city model structure schedules
2020-10-22 11:02:41 -04:00
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
2020-12-15 15:15:40 -05:00
Contributors Pilar Monsalvete pilar_monsalvete@yahoo.es
2020-10-22 11:02:41 -04:00
"""
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
2020-10-22 11:02:41 -04:00
2020-12-15 15:15:40 -05:00
class TestSchedulesFactory(TestCase):
2020-10-22 11:02:41 -04:00
"""
2020-12-15 15:15:40 -05:00
TestSchedulesFactory TestCase
2020-10-22 11:02:41 -04:00
"""
def setUp(self) -> None:
"""
Test setup
:return: None
"""
2020-10-27 12:53:29 -04:00
self._city_gml_with_usage = None
2020-10-22 11:02:41 -04:00
self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve()
2020-10-27 12:53:29 -04:00
@property
def _handler(self):
if self._city_gml_with_usage.name == 'New York':
handler = '{0}_{1}'
2020-12-15 14:57:46 -05:00
return handler.format(self._city_gml_with_usage.country_code,
self._city_gml_with_usage.name.lower().replace(' ', '_'))
2020-10-27 12:53:29 -04:00
return self._city_gml_with_usage.country_code
def _get_citygml_with_usage(self):
if self._city_gml_with_usage is None:
file_path = (self._example_path / '20buildings.gml').resolve()
2020-10-27 12:53:29 -04:00
self._city_gml_with_usage = GeometryFactory('citygml', file_path).city
self.assertIsNotNone(self._city_gml_with_usage, 'city is none')
UsageFactory(self._handler, self._city_gml_with_usage)
self.assertIsNotNone(self._city_gml_with_usage, 'city with usage is none')
return self._city_gml_with_usage
2020-10-22 11:02:41 -04:00
2020-12-15 14:57:46 -05:00
def test_comnet_archetypes(self):
2020-10-27 12:53:29 -04:00
city = self._get_citygml_with_usage()
2020-12-15 14:57:46 -05:00
occupancy_handler = 'comnet'
SchedulesFactory(occupancy_handler, city)
2020-10-22 11:02:41 -04:00
for building in city.buildings:
2020-10-27 13:19:50 -04:00
for usage_zone in building.usage_zones:
self.assertTrue(usage_zone.schedules)