forked from s_ranjbar/city_retrofit
94c593b651
re-structured weather.py file accordingly (now in weather_factory.helpers
49 lines
1.7 KiB
Python
49 lines
1.7 KiB
Python
"""
|
|
TestOccupancyFactory test and validate the city model structure occupancy parameters
|
|
SPDX - License - Identifier: LGPL - 3.0 - or -later
|
|
Copyright © 2020 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
|
|
"""
|
|
from pathlib import Path
|
|
from unittest import TestCase
|
|
|
|
from factories.geometry.geometry_factory import GeometryFactory
|
|
from factories.usage.usage_factory import UsageFactory
|
|
from factories.occupancy.occupancy_factory import OccupancyFactory
|
|
|
|
|
|
class TestOccupancyFactory(TestCase):
|
|
"""
|
|
TestOccupancyFactory TestCase
|
|
"""
|
|
|
|
def setUp(self) -> None:
|
|
"""
|
|
Test setup
|
|
:return: None
|
|
"""
|
|
self._city_gml_with_usage = None
|
|
self._example_path = (Path(__file__).parent.parent / 'tests_data').resolve()
|
|
|
|
@property
|
|
def _handler(self):
|
|
if self._city_gml_with_usage.name == 'New York':
|
|
handler = '{0}_{1}'
|
|
return handler.format(self._city_gml_with_usage.country_code, self._city_gml_with_usage.name.lower().replace(' ', '_'))
|
|
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 / 'attributes.gml').resolve()
|
|
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
|
|
|
|
def test_demo(self):
|
|
city = self._get_citygml_with_usage()
|
|
OccupancyFactory('demo', city)
|
|
for building in city.buildings:
|
|
for usage_zone in building.usage_zones:
|
|
self.assertTrue(usage_zone.schedules)
|