city_retrofit/unittests/test_sensors_factory.py
2022-03-08 19:19:52 -05:00

59 lines
2.0 KiB
Python

"""
TestSensorsFactory test and validate the city model structure schedules
SPDX - License - Identifier: LGPL - 3.0 - or -later
Copyright © 2021 Project Author Guille Gutierrez guillermo.gutierrezmorote@concordia.ca
"""
from pathlib import Path
from unittest import TestCase
from city_model_structure.building import Building
from city_model_structure.buildings_cluster import BuildingsCluster
from city_model_structure.city import City
from imports.sensors_factory import SensorsFactory
class TestSensorsFactory(TestCase):
"""
TestSchedulesFactory TestCase
"""
def setUp(self) -> None:
"""
Configure test environment
:return:
"""
self._city = TestSensorsFactory._mockup_city()
self._end_point = (Path(__file__).parent /
'tests_data/EV-GM energy demand weekly report_01-26-20_04-30.csv').resolve()
@staticmethod
def _mockup_city():
lower_corner = [0, 0, 0]
upper_corner = [10, 10, 10]
srs_name = 'Mockup_city'
buildings = []
lod = 2
surfaces = []
year_of_construction = 2021
function = "office"
city = City(lower_corner, upper_corner, srs_name)
buildings.append(Building("EV", lod, surfaces, year_of_construction, function, lower_corner))
buildings.append(Building("GM", lod, surfaces, year_of_construction, function, lower_corner))
buildings.append(Building("MB", lod, surfaces, year_of_construction, function, lower_corner))
for building in buildings:
city.add_city_object(building)
buildings_cluster = BuildingsCluster("GM_MB_EV", buildings)
city.add_city_objects_cluster(buildings_cluster)
return city
def test_city_with_sensors(self):
"""
Load concordia sensors and verify it
"""
SensorsFactory('cec', self._city, self._end_point).enrich()
SensorsFactory('cgf', self._city, self._end_point).enrich()
SensorsFactory('ct', self._city, self._end_point).enrich()
for city_object in self._city.city_objects:
print(city_object.name, len(city_object.sensors))
for sensor in city_object.sensors:
print(sensor.name)